| Conditions | 3 |
| Paths | 3 |
| Total Lines | 18 |
| Code Lines | 9 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 1 | Features | 1 |
| 1 | <?php |
||
| 38 | public static function enabled($name = null) |
||
| 39 | { |
||
| 40 | // get widget class-namespace callback and single class name |
||
| 41 | self::$class = get_called_class(); |
||
| 42 | self::$name = Str::lastIn(self::$class, '\\', true); |
||
| 43 | |||
| 44 | $wData = AppRecord::getItem('widget', self::$name); |
||
| 45 | // widget is not founded, deny run |
||
| 46 | if ($wData === null) { |
||
| 47 | if (App::$Debug !== null) { |
||
| 48 | App::$Debug->addMessage(__('Widget with name %name%[%class%] is not found', ['name' => self::$name, 'class' => self::$class])); |
||
| 49 | } |
||
| 50 | return null; |
||
| 51 | } |
||
| 52 | |||
| 53 | // if widget is disabled - lets return nothing |
||
| 54 | return !(bool)$wData->disabled; |
||
| 55 | } |
||
| 56 | |||
| 57 | } |
If an expression can have both
false, andnullas possible values. It is generally a good practice to always use strict comparison to clearly distinguish between those two values.