| Conditions | 8 |
| Paths | 14 |
| Total Lines | 32 |
| Code Lines | 17 |
| Lines | 7 |
| Ratio | 21.88 % |
| Changes | 3 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 17 | public static function widget(array $params = null) |
||
|
|
|||
| 18 | { |
||
| 19 | if (self::$class === null) { |
||
| 20 | self::$class = get_called_class(); |
||
| 21 | } |
||
| 22 | |||
| 23 | // check if class exist |
||
| 24 | if (!class_exists(self::$class)) { |
||
| 25 | return 'Error: Widget is not founded: ' . App::$Security->strip_tags(self::$class); |
||
| 26 | } |
||
| 27 | |||
| 28 | // init class and pass properties |
||
| 29 | $object = new self::$class; |
||
| 30 | View Code Duplication | if (Obj::isArray($params) && count($params) > 0) { |
|
| 31 | foreach ($params as $property => $value) { |
||
| 32 | if (property_exists($object, $property)) { |
||
| 33 | $object->$property = $value; |
||
| 34 | } |
||
| 35 | } |
||
| 36 | } |
||
| 37 | |||
| 38 | // prepare output |
||
| 39 | $out = null; |
||
| 40 | try { |
||
| 41 | $object->init(); |
||
| 42 | $out = $object->display(); |
||
| 43 | } catch (\Exception $e) { |
||
| 44 | throw $e; |
||
| 45 | } |
||
| 46 | |||
| 47 | return $out; |
||
| 48 | } |
||
| 49 | |||
| 53 | } |