1 | <?php |
||
7 | abstract class AbstractCerberus |
||
8 | { |
||
9 | |||
10 | protected $options = []; |
||
11 | protected $results = []; |
||
12 | protected $result = []; |
||
13 | protected $score = 0; |
||
14 | protected $soteria; |
||
15 | |||
16 | function __construct() |
||
21 | |||
22 | |||
23 | 4 | protected function processWrappers($handler) |
|
24 | { |
||
25 | 4 | $options = $this->getOption('Detection'); |
|
26 | |||
27 | 4 | foreach ($handler->getWrappers() as $wrapper) { |
|
28 | |||
29 | 4 | $wrapper->setOptions($handler->getValue(), $options['Rules']); |
|
30 | 4 | $wrapper->process(); |
|
31 | 4 | $this->addResult($wrapper->getScore(), $wrapper->getResult()); |
|
32 | 4 | } |
|
33 | 4 | } |
|
34 | |||
35 | 4 | private function getOption($name) |
|
43 | |||
44 | 4 | private function hasOption($name) |
|
48 | |||
49 | 4 | protected function addResult($score, $result) |
|
50 | { |
||
51 | 4 | if (is_array($result)) { |
|
52 | 2 | $this->addScore($score); |
|
53 | 2 | $this->result = array_merge($this->result, $result); |
|
54 | 2 | } |
|
55 | 4 | return $this; |
|
56 | } |
||
57 | |||
58 | /** |
||
59 | * @param $score |
||
60 | * @return $this |
||
61 | */ |
||
62 | 2 | private function addScore($score) |
|
67 | |||
68 | 4 | protected function clearResults() |
|
74 | |||
75 | /** |
||
76 | * @return array |
||
77 | */ |
||
78 | protected function getOptions() |
||
82 | |||
83 | /** |
||
84 | * @param file|array $options |
||
85 | * @return $this |
||
86 | */ |
||
87 | 4 | public function setOptions($options = []) |
|
110 | |||
111 | 4 | private function arrayMergeRecursiveDistinct($merged = [], $array2 = []) |
|
126 | } |
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.