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() |
||
84 | |||
85 | /** |
||
86 | * @inheritdoc |
||
87 | */ |
||
88 | public static function populateRecord($record, $row) |
||
96 | |||
97 | /** |
||
98 | * @inheritdoc |
||
99 | * @throws \yii\base\InvalidConfigException |
||
100 | * @return ElementMetricQuery |
||
101 | */ |
||
102 | public static function find() |
||
116 | |||
117 | /** |
||
118 | * @inheritdoc |
||
119 | */ |
||
120 | public function resetScore() |
||
125 | |||
126 | /** |
||
127 | * @inheritdoc |
||
128 | */ |
||
129 | public function beforeSave($insert) |
||
136 | |||
137 | /** |
||
138 | * @inheritdoc |
||
139 | */ |
||
140 | public static function instantiate($row) |
||
145 | |||
146 | /** |
||
147 | * @inheritdoc |
||
148 | */ |
||
149 | public function rules() |
||
201 | |||
202 | |||
203 | /******************************************* |
||
204 | * METRIC INTERFACE |
||
205 | *******************************************/ |
||
206 | |||
207 | /** |
||
208 | * @inheritdoc |
||
209 | * @throws \ReflectionException |
||
210 | */ |
||
211 | public static function displayName(): string |
||
220 | |||
221 | /** |
||
222 | * @inheritdoc |
||
223 | */ |
||
224 | public function getWeight(): float |
||
228 | |||
229 | /** |
||
230 | * @inheritdoc |
||
231 | */ |
||
232 | public function getVersion(): string |
||
236 | |||
237 | /** |
||
238 | * @inheritdoc |
||
239 | */ |
||
240 | public function getScore(): float |
||
248 | |||
249 | /** |
||
250 | * @return DateTime |
||
251 | */ |
||
252 | public function getDateCalculated(): DateTime |
||
270 | |||
271 | /** |
||
272 | * @return DateTime |
||
273 | */ |
||
274 | protected function defaultDateCalculated(): DateTime |
||
280 | |||
281 | |||
282 | /******************************************* |
||
283 | * SETTINGS |
||
284 | *******************************************/ |
||
285 | |||
286 | /** |
||
287 | * @param string $attribute |
||
288 | * @return mixed |
||
289 | */ |
||
290 | public function getSettingsValue(string $attribute) |
||
298 | |||
299 | /** |
||
300 | * @param string $attribute |
||
301 | * @param $value |
||
302 | * @return $this |
||
303 | */ |
||
304 | public function setSettingsValue(string $attribute, $value) |
||
314 | |||
315 | |||
316 | /******************************************* |
||
317 | * CONFIGURATION |
||
318 | *******************************************/ |
||
319 | |||
320 | /** |
||
321 | * @return array |
||
322 | */ |
||
323 | public function toConfig(): array |
||
327 | } |
||
328 |