1 | <?php |
||
22 | abstract class ElementMetricCollection extends ElementMetric |
||
23 | { |
||
24 | /** |
||
25 | * @return array |
||
26 | */ |
||
27 | const METRICS = []; |
||
28 | |||
29 | /** |
||
30 | * @var MetricInterface[] |
||
31 | */ |
||
32 | private $metrics; |
||
33 | |||
34 | |||
35 | /******************************************* |
||
36 | * METRIC INTERFACE |
||
37 | *******************************************/ |
||
38 | |||
39 | /** |
||
40 | * @inheritdoc |
||
41 | */ |
||
42 | protected function calculateScore(): float |
||
54 | |||
55 | /** |
||
56 | * @inheritdoc |
||
57 | */ |
||
58 | public function resetScore() |
||
66 | |||
67 | |||
68 | /******************************************* |
||
69 | * METRICS (CHILDREN) |
||
70 | *******************************************/ |
||
71 | |||
72 | /** |
||
73 | * @return MetricInterface[] |
||
74 | */ |
||
75 | public function getMetrics(): array |
||
85 | |||
86 | /** |
||
87 | * @return array |
||
88 | */ |
||
89 | protected function loadMetrics(): array |
||
100 | |||
101 | /** |
||
102 | * @param array $metrics |
||
103 | * @return $this |
||
104 | */ |
||
105 | public function setMetrics(array $metrics = []) |
||
119 | |||
120 | /** |
||
121 | * @noinspection PhpDocMissingThrowsInspection |
||
122 | * |
||
123 | * @param $metric |
||
124 | * @return MetricInterface |
||
125 | */ |
||
126 | protected function createMetric($metric): MetricInterface |
||
145 | |||
146 | /******************************************* |
||
147 | * CHILDREN (RECORDS) |
||
148 | *******************************************/ |
||
149 | |||
150 | /** |
||
151 | * @return ElementMetricQuery |
||
152 | */ |
||
153 | public function getChildren(): ElementMetricQuery |
||
167 | |||
168 | /******************************************* |
||
169 | * VALIDATE (CHILD RECORDS) |
||
170 | *******************************************/ |
||
171 | |||
172 | /** |
||
173 | * @inheritdoc |
||
174 | */ |
||
175 | public function beforeValidate() |
||
188 | |||
189 | /******************************************* |
||
190 | * SAVE (CHILD RECORDS) |
||
191 | *******************************************/ |
||
192 | |||
193 | /** |
||
194 | * @inheritdoc |
||
195 | */ |
||
196 | public function beforeSave($insert) |
||
219 | |||
220 | /** |
||
221 | * @inheritdoc |
||
222 | */ |
||
223 | public function afterSave($insert, $changedAttributes) |
||
251 | } |
||
252 |