Pass   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 4
eloc 15
c 0
b 0
f 0
dl 0
loc 58
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A record() 0 9 3
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace Drupal\qa;
6
7
use Drupal\qa\Plugin\QaCheckInterface;
8
9
/**
10
 * Pass represents the results of a QaCheck run, aka a "Pass" in a check suite.
11
 */
12
class Pass {
13
14
  /**
15
   * The QaCheck instance of which this is a pass.
16
   *
17
   * @var \Drupal\qa\Plugin\QaCheckInterface
18
   */
19
  public $check;
20
21
  /**
22
   * The pass lifecycle.
23
   *
24
   * @var \Drupal\qa\Same
25
   */
26
  public $life;
27
28
  /**
29
   * Did all steps succeed ?
30
   *
31
   * @var bool
32
   */
33
  public $ok;
34
35
  /**
36
   * Serializable array for the results.
37
   *
38
   * @var array
39
   */
40
  public $result;
41
42
  /**
43
   * Pass constructor.
44
   *
45
   * @param \Drupal\qa\Plugin\QaCheckInterface $check
46
   *   A check on which to report.
47
   */
48
  public function __construct(QaCheckInterface $check) {
49
    $this->life = new Same();
50
    $this->ok = TRUE;
51
    $this->check = $check;
52
    $this->result = [];
53
  }
54
55
  /**
56
   * Record results from one of the checks in a control pass.
57
   *
58
   * @param Result|null $checkResult
59
   *   A check result to store.
60
   */
61
  public function record(?Result $checkResult) {
62
    if (empty($checkResult)) {
63
      return;
64
    }
65
    if (!$checkResult->ok) {
66
      $this->ok = FALSE;
67
    }
68
    $this->result[$checkResult->name] = $checkResult;
69
    $this->life->modify();
70
  }
71
72
}
73