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() |
||
92 | |||
93 | /** |
||
94 | * @inheritdoc |
||
95 | */ |
||
96 | public static function find() |
||
110 | |||
111 | /** |
||
112 | * @inheritdoc |
||
113 | */ |
||
114 | public static function instantiate($row) |
||
119 | |||
120 | /** |
||
121 | * @inheritdoc |
||
122 | */ |
||
123 | public function rules() |
||
175 | |||
176 | |||
177 | /******************************************* |
||
178 | * METRIC INTERFACE |
||
179 | *******************************************/ |
||
180 | |||
181 | /** |
||
182 | * @inheritdoc |
||
183 | * @throws \ReflectionException |
||
184 | */ |
||
185 | public static function displayName(): string |
||
192 | |||
193 | /** |
||
194 | * @inheritdoc |
||
195 | */ |
||
196 | public function getWeight(): float |
||
200 | |||
201 | /** |
||
202 | * @inheritdoc |
||
203 | */ |
||
204 | public function getVersion(): string |
||
208 | |||
209 | /** |
||
210 | * @inheritdoc |
||
211 | */ |
||
212 | public function getScore(): float |
||
220 | |||
221 | /** |
||
222 | * @return \DateTime|null |
||
223 | */ |
||
224 | public function getDateCalculated() |
||
240 | |||
241 | |||
242 | /******************************************* |
||
243 | * SETTINGS |
||
244 | *******************************************/ |
||
245 | |||
246 | /** |
||
247 | * @param string $attribute |
||
248 | * @return mixed |
||
249 | */ |
||
250 | public function getSettingsValue(string $attribute) |
||
258 | |||
259 | /** |
||
260 | * @param string $attribute |
||
261 | * @param $value |
||
262 | * @return $this |
||
263 | */ |
||
264 | public function setSettingsValue(string $attribute, $value) |
||
274 | |||
275 | |||
276 | /******************************************* |
||
277 | * CONFIGURATION |
||
278 | *******************************************/ |
||
279 | |||
280 | /** |
||
281 | * @return array |
||
282 | */ |
||
283 | public function toConfig(): array |
||
287 | } |
||
288 |