1 | <?php |
||
5 | class CerberusModel |
||
6 | { |
||
7 | /** |
||
8 | * @var array |
||
9 | */ |
||
10 | private $references = []; |
||
11 | |||
12 | /** |
||
13 | * @var int |
||
14 | */ |
||
15 | private $score = 0; |
||
16 | |||
17 | /** |
||
18 | * @var array |
||
19 | */ |
||
20 | private $result = []; |
||
21 | |||
22 | /** |
||
23 | * DetectModel constructor. |
||
24 | * @param array $references |
||
25 | * @param int $score |
||
26 | * @param array $result |
||
27 | */ |
||
28 | 4 | function __construct($references = [], $score = 0, $result = []) |
|
34 | |||
35 | /** |
||
36 | * @return array |
||
37 | */ |
||
38 | public function toArray() |
||
39 | { |
||
40 | return [ |
||
41 | 'results' => [ |
||
42 | "array" => $this->decodedResult(), |
||
43 | 'string' => $this->getResult(), |
||
44 | ], |
||
45 | 'references' => $this->getReferences(), |
||
46 | 'score' => $this->getScore() |
||
47 | ]; |
||
48 | } |
||
49 | |||
50 | /** |
||
51 | * @return array |
||
52 | */ |
||
53 | private function decodedResult() |
||
54 | { |
||
55 | return $this->result; |
||
56 | } |
||
57 | |||
58 | /** |
||
59 | * @return false|string |
||
60 | */ |
||
61 | 4 | public function getResult() |
|
65 | |||
66 | /** |
||
67 | * @return array |
||
68 | */ |
||
69 | public function getReferences() |
||
70 | { |
||
71 | return $this->references; |
||
72 | } |
||
73 | |||
74 | /** |
||
75 | * @return integer |
||
76 | */ |
||
77 | 4 | public function getScore() |
|
81 | |||
82 | /** |
||
83 | * @return bool |
||
84 | */ |
||
85 | public function hasScore() |
||
89 | |||
90 | } |
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.