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