1 | <?php |
||
8 | abstract class AbstractCheck implements CheckInterface |
||
9 | { |
||
10 | /** |
||
11 | * @var null|string |
||
12 | */ |
||
13 | protected $checkNode = self::CHECK_NODE_DEFAULT; |
||
14 | |||
15 | /** |
||
16 | * @var CheckResult |
||
17 | */ |
||
18 | protected $lastCheckResult = null; |
||
19 | |||
20 | /** |
||
21 | * AbstractCheck constructor. |
||
22 | * |
||
23 | * @param null $checkNode |
||
24 | */ |
||
25 | 5 | public function __construct($checkNode = null) |
|
31 | |||
32 | /** |
||
33 | * @return string |
||
34 | */ |
||
35 | 1 | public function getCheckComponent() |
|
39 | |||
40 | /** |
||
41 | * @return string |
||
42 | */ |
||
43 | 1 | public function getCheckGroup() |
|
47 | |||
48 | /** |
||
49 | * @return null|string |
||
50 | */ |
||
51 | 1 | public function getCheckNode() |
|
55 | |||
56 | /** |
||
57 | * @return string |
||
58 | */ |
||
59 | 1 | public function getCheckIdent() |
|
63 | |||
64 | /** |
||
65 | * @return null|string |
||
66 | */ |
||
67 | 1 | public function getIndent() |
|
71 | |||
72 | /** |
||
73 | * @return CheckResult |
||
74 | */ |
||
75 | 1 | public function getLastCheckResult() |
|
79 | |||
80 | /** |
||
81 | * @return CheckResult |
||
82 | */ |
||
83 | 3 | public function performCheck() |
|
84 | { |
||
85 | try { |
||
86 | 3 | $this->check(); |
|
87 | 1 | $checkResult = CheckResult::okResult(); |
|
88 | 3 | } catch (CheckException $error) { |
|
89 | 2 | $checkResult = CheckResult::errorResult($error->getCode(), $error); |
|
90 | } |
||
91 | |||
92 | 3 | $this->setLastCheckResult($checkResult); |
|
93 | |||
94 | 3 | return $checkResult; |
|
95 | } |
||
96 | |||
97 | /** |
||
98 | * @param string $checkNode |
||
99 | */ |
||
100 | 5 | protected function setCheckNode($checkNode) |
|
104 | |||
105 | /** |
||
106 | * @param CheckResult $lastCheckResult |
||
107 | */ |
||
108 | 3 | protected function setLastCheckResult(CheckResult $lastCheckResult) |
|
112 | } |
||
113 |