Total Complexity | 7 |
Total Lines | 67 |
Duplicated Lines | 0 % |
Changes | 0 |
1 | <?php |
||
14 | class StatusModel extends StaticModel implements StatusInterface |
||
15 | { |
||
16 | const STATUS_CREATED = "created"; |
||
17 | const STATUS_ACTIVE = "active"; |
||
18 | |||
19 | /** @var integer $id*/ |
||
20 | public $id; |
||
21 | |||
22 | /** @var string $label */ |
||
23 | public $label = ''; |
||
24 | |||
25 | /** @var string */ |
||
26 | public $description; |
||
27 | |||
28 | public static $keyColumn = 'id'; |
||
29 | |||
30 | public function getModelAttributes() |
||
31 | { |
||
32 | return [ |
||
33 | self::STATUS_CREATED => [ |
||
34 | 'id' => self::STATUS_CREATED, |
||
35 | 'label' => Yii::t('app', 'Created'), |
||
36 | 'description' => Yii::t('app', 'Was created'), |
||
37 | ], |
||
38 | |||
39 | ]; |
||
40 | } |
||
41 | |||
42 | /** |
||
43 | * Returns all status names in plain array without labels |
||
44 | * @return string[] |
||
45 | */ |
||
46 | public static function getAllStatusNames() |
||
47 | { |
||
48 | $out = []; |
||
49 | foreach ((new static)->getModelAttributes() as $attributes) { |
||
50 | $out[] = $attributes['label']; |
||
51 | } |
||
52 | return $out; |
||
53 | } |
||
54 | |||
55 | /** |
||
56 | * @param string $id |
||
57 | * @return bool |
||
58 | */ |
||
59 | public static function isStatus($id) { |
||
60 | return (!self::getById($id) === false); |
||
61 | } |
||
62 | |||
63 | /** |
||
64 | * @param string $id |
||
65 | * @return null|string |
||
66 | */ |
||
67 | public static function getStatusLabel($id) { |
||
73 | } |
||
74 | |||
75 | /** |
||
76 | * {@inheritdoc} |
||
77 | */ |
||
78 | public function isActive($id) |
||
81 | } |
||
82 | } |