1 | <?php |
||
34 | abstract class ElementMetric extends ActiveRecordWithId implements SavableMetricInterface |
||
35 | { |
||
36 | use ElementAttribute; |
||
37 | |||
38 | /** |
||
39 | * The default score weight |
||
40 | */ |
||
41 | const WEIGHT = 1; |
||
42 | |||
43 | /** |
||
44 | * The default metric version |
||
45 | */ |
||
46 | const VERSION = '1.0'; |
||
47 | |||
48 | /** |
||
49 | * The table alias |
||
50 | */ |
||
51 | const TABLE_ALIAS = 'scorecard_element_metrics'; |
||
52 | |||
53 | /** |
||
54 | * The Active Query class |
||
55 | */ |
||
56 | const ACTIVE_QUERY_CLASS = ElementMetricQuery::class; |
||
57 | |||
58 | /** |
||
59 | * @inheritdoc |
||
60 | */ |
||
61 | protected $getterPriorityAttributes = ['elementId', 'score', 'dateCalculated']; |
||
62 | |||
63 | /** |
||
64 | * @return float |
||
65 | */ |
||
66 | abstract protected function calculateScore(): float; |
||
67 | |||
68 | /** |
||
69 | * @inheritdoc |
||
70 | */ |
||
71 | public function init() |
||
90 | |||
91 | /** |
||
92 | * @inheritdoc |
||
93 | */ |
||
94 | public static function populateRecord($record, $row) |
||
101 | |||
102 | /** |
||
103 | * @inheritdoc |
||
104 | * @throws \yii\base\InvalidConfigException |
||
105 | * @return ElementMetricQuery |
||
106 | */ |
||
107 | public static function find() |
||
121 | |||
122 | /** |
||
123 | * @inheritdoc |
||
124 | */ |
||
125 | public function resetScore() |
||
130 | |||
131 | /** |
||
132 | * @inheritdoc |
||
133 | */ |
||
134 | public function beforeSave($insert) |
||
141 | |||
142 | /** |
||
143 | * @inheritdoc |
||
144 | */ |
||
145 | public static function instantiate($row) |
||
150 | |||
151 | /** |
||
152 | * @inheritdoc |
||
153 | */ |
||
154 | public function rules() |
||
206 | |||
207 | |||
208 | /******************************************* |
||
209 | * METRIC INTERFACE |
||
210 | *******************************************/ |
||
211 | |||
212 | /** |
||
213 | * @inheritdoc |
||
214 | * @throws \ReflectionException |
||
215 | */ |
||
216 | public static function displayName(): string |
||
225 | |||
226 | /** |
||
227 | * @inheritdoc |
||
228 | */ |
||
229 | public function getWeight(): float |
||
233 | |||
234 | /** |
||
235 | * @inheritdoc |
||
236 | */ |
||
237 | public function getVersion(): string |
||
241 | |||
242 | /** |
||
243 | * @inheritdoc |
||
244 | */ |
||
245 | public function getScore(): float |
||
253 | |||
254 | /** |
||
255 | * @return DateTime |
||
256 | */ |
||
257 | public function getDateCalculated(): DateTime |
||
275 | |||
276 | /** |
||
277 | * @return DateTime |
||
278 | */ |
||
279 | protected function defaultDateCalculated(): DateTime |
||
285 | |||
286 | |||
287 | /******************************************* |
||
288 | * SETTINGS |
||
289 | *******************************************/ |
||
290 | |||
291 | /** |
||
292 | * @param string $attribute |
||
293 | * @return mixed |
||
294 | */ |
||
295 | public function getSettingsValue(string $attribute) |
||
303 | |||
304 | /** |
||
305 | * @param string $attribute |
||
306 | * @param $value |
||
307 | * @return $this |
||
308 | */ |
||
309 | public function setSettingsValue(string $attribute, $value) |
||
319 | |||
320 | |||
321 | /******************************************* |
||
322 | * CONFIGURATION |
||
323 | *******************************************/ |
||
324 | |||
325 | /** |
||
326 | * @return array |
||
327 | */ |
||
328 | public function toConfig(): array |
||
332 | } |
||
333 |