| Total Complexity | 4 |
| Total Lines | 44 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 19 | class Notification |
||
| 20 | { |
||
| 21 | |||
| 22 | const TYPE_INFO = "0"; |
||
| 23 | const TYPE_SUCCESS = "1"; |
||
| 24 | const TYPE_ERROR = "2"; |
||
| 25 | |||
| 26 | /**Registers AssetBundle in a view. |
||
| 27 | * Returns string with Javascript info() function call. |
||
| 28 | * @param $text |
||
| 29 | * @param $type |
||
| 30 | * @return string |
||
| 31 | */ |
||
| 32 | public static function notification($text, $type): string |
||
| 33 | { |
||
| 34 | NotificationAsset::register(Yii::$app->getView()); |
||
| 35 | return Html::script("info(\"{$text}\",{$type});"); |
||
| 36 | } |
||
| 37 | |||
| 38 | /** Alias to self::notification with INFO type. |
||
| 39 | * @param $text |
||
| 40 | * @return string |
||
| 41 | */ |
||
| 42 | public static function info($text): string |
||
| 43 | { |
||
| 44 | return self::notification($text, self::TYPE_INFO); |
||
| 45 | } |
||
| 46 | |||
| 47 | /** Alias to self::notification with ERROR type. |
||
| 48 | * @param $text |
||
| 49 | * @return string |
||
| 50 | */ |
||
| 51 | public static function error($text): string |
||
| 52 | { |
||
| 53 | return self::notification($text, self::TYPE_ERROR); |
||
| 54 | } |
||
| 55 | |||
| 56 | /** Alias to self::notification with SUCCESS type. |
||
| 57 | * @param $text |
||
| 58 | * @return string |
||
| 59 | */ |
||
| 60 | public static function success($text): string |
||
| 63 | } |
||
| 64 | |||
| 65 | } |