aboutsummaryrefslogtreecommitdiff
path: root/classes/IsisAudit.php
blob: f2435a95121fe605af55a3c16ea8358295c10aea (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
39
40
41
42
43
44
45
46
47
48
49
50
<?php

/**
 * Methods for auditing an Isis database.
 */
class IsisAudit extends IsisFinder {
  /**
   * @var $log
   *   Log messages. 
   */
  var $log;

  /**
   * Class logger.
   *
   * @param $message
   *   Log message.
   */
  function logger($message) {
    $this->log[] = $message;
  }

  /**
   * 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) {
        $this->logger("Field ". $field['name'] ." is configured for repetitions but no repetitions found.");
      }
      elseif (!$field['repeat'] && $repetition) {
        $this->logger("Field ". $field['name'] ." is not configured for repetitions but a repetition was found for entry ". $repetition[0] .".");
      }

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

          if (!$next_subfield) {
            $this->logger("No occurrences found for field ". $field['name'] ." and subfield $subfield.");
          }
        }
      }
    }
  }
}