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']; |
||
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 | /******************************************* |
||
223 | * SETTINGS |
||
224 | *******************************************/ |
||
225 | |||
226 | /** |
||
227 | * @param string $attribute |
||
228 | * @return mixed |
||
229 | */ |
||
230 | public function getSettingsValue(string $attribute) |
||
238 | |||
239 | /** |
||
240 | * @param string $attribute |
||
241 | * @param $value |
||
242 | * @return $this |
||
243 | */ |
||
244 | public function setSettingsValue(string $attribute, $value) |
||
254 | |||
255 | |||
256 | /******************************************* |
||
257 | * CONFIGURATION |
||
258 | *******************************************/ |
||
259 | |||
260 | /** |
||
261 | * @return array |
||
262 | */ |
||
263 | public function toConfig(): array |
||
267 | } |
||
268 |