aboutsummaryrefslogtreecommitdiff
path: root/classes/IsisAudit.php
blob: 79cbe26526be5d90117051f934f6035577bee26a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php

/**
 * Methods for auditing an Isis database.
 */
class IsisAudit extends IsisFinder {
  /**
   * Run a standard audit procedure.
   *
   * @todo
   *   Test.
   */
  public function run() {
    foreach ($this->format['fields'] as $field) {
      $field_name = $this->getFieldName($field);
      $repetition = $this->nextRepetition(null, $field_name);

      // Check for repetitions.
      if ($field['repeat'] && !$repetition)
      {
        echo "Field $field_name is configured for repetitions but no repetitions found.\n";
      }
      elseif (!$field['repeat'] && $repetition) {
        echo "Field $field_name is not configured for repetitions but a repetition was found.\n";
      }

      // Check for subfields.
      foreach ($field['subfields'] as $subfield) {
        $subfield_name = $this->getSubfieldName($field, $subfield);
        $next_subfield = $isis->nextSubfield(null, $field_name, $subfield_name);

        if (!$next_subfield) {
          echo "No occurrences found for field $field_name and subfield $subfield_name\n";
        }
      }
    }
  }
}