aboutsummaryrefslogtreecommitdiff
path: root/classes/IsisAudit.php
blob: 63446e169ebd2b395b6998a0b959642e81a97c6b (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
<?php

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

      // 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 for entry ". $repetition[0] .".\n";
      }

      // Check for subfields.
      if (isset($field['subfields'])) {
        foreach ($field['subfields'] as $subfield) {
          $next_subfield = $this->nextSubfield($field, $subfield);

          if (!$next_subfield) {
            echo "No occurrences found for field ". $field['name'] ." and subfield $subfield\n";
          }
        }
      }
    }
  }
}