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 | * @return float |
||
41 | */ |
||
42 | protected function calculateScore(): float |
||
54 | |||
55 | |||
56 | /******************************************* |
||
57 | * METRICS (CHILDREN) |
||
58 | *******************************************/ |
||
59 | |||
60 | /** |
||
61 | * @return MetricInterface[] |
||
62 | */ |
||
63 | public function getMetrics(): array |
||
73 | |||
74 | /** |
||
75 | * @return array |
||
76 | */ |
||
77 | protected function loadMetrics(): array |
||
88 | |||
89 | /** |
||
90 | * @param array $metrics |
||
91 | * @return $this |
||
92 | */ |
||
93 | public function setMetrics(array $metrics = []) |
||
107 | |||
108 | /** |
||
109 | * @noinspection PhpDocMissingThrowsInspection |
||
110 | * |
||
111 | * @param $metric |
||
112 | * @return MetricInterface |
||
113 | */ |
||
114 | protected function createMetric($metric): MetricInterface |
||
133 | |||
134 | /******************************************* |
||
135 | * CHILDREN (RECORDS) |
||
136 | *******************************************/ |
||
137 | |||
138 | /** |
||
139 | * @return ElementMetricQuery |
||
140 | */ |
||
141 | public function getChildren(): ElementMetricQuery |
||
155 | |||
156 | /******************************************* |
||
157 | * VALIDATE (CHILD RECORDS) |
||
158 | *******************************************/ |
||
159 | |||
160 | /** |
||
161 | * @inheritdoc |
||
162 | */ |
||
163 | public function beforeValidate() |
||
176 | |||
177 | /******************************************* |
||
178 | * SAVE (CHILD RECORDS) |
||
179 | *******************************************/ |
||
180 | |||
181 | /** |
||
182 | * @inheritdoc |
||
183 | */ |
||
184 | public function beforeSave($insert) |
||
207 | |||
208 | /** |
||
209 | * @inheritdoc |
||
210 | */ |
||
211 | public function afterSave($insert, $changedAttributes) |
||
239 | } |
||
240 |