rmrevin /
yii2-fontawesome
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | /** |
||
| 3 | * UnorderedList.php |
||
| 4 | * @author Revin Roman |
||
| 5 | * @link https://rmrevin.com |
||
| 6 | */ |
||
| 7 | |||
| 8 | namespace rmrevin\yii\fontawesome\component; |
||
| 9 | |||
| 10 | use rmrevin\yii\fontawesome\FA; |
||
| 11 | use yii\helpers\ArrayHelper; |
||
| 12 | use yii\helpers\Html; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * Class UnorderedList |
||
| 16 | * @package rmrevin\yii\fontawesome\component |
||
| 17 | */ |
||
| 18 | class UnorderedList |
||
| 19 | { |
||
| 20 | |||
| 21 | /** |
||
| 22 | * @deprecated |
||
| 23 | * @var string |
||
| 24 | */ |
||
| 25 | public static $defaultTag = 'ul'; |
||
| 26 | |||
| 27 | /** |
||
| 28 | * @deprecated |
||
| 29 | * @var string |
||
| 30 | */ |
||
| 31 | private $tag; |
||
| 32 | |||
| 33 | /** |
||
| 34 | * @var array |
||
| 35 | */ |
||
| 36 | protected $options = []; |
||
| 37 | |||
| 38 | /** |
||
| 39 | * @var array |
||
| 40 | */ |
||
| 41 | protected $items = []; |
||
| 42 | |||
| 43 | /** |
||
| 44 | * @param array $options |
||
| 45 | */ |
||
| 46 | 2 | public function __construct($options = []) |
|
| 47 | { |
||
| 48 | 2 | Html::addCssClass($options, FA::$cssPrefix . '-ul'); |
|
| 49 | |||
| 50 | $options['item'] = function ($item, $index) { |
||
| 51 | 2 | return call_user_func($item, $index); |
|
| 52 | }; |
||
| 53 | |||
| 54 | 2 | $this->options = $options; |
|
| 55 | 2 | } |
|
| 56 | |||
| 57 | /** |
||
| 58 | * @return string |
||
| 59 | */ |
||
| 60 | 2 | public function __toString() |
|
| 61 | { |
||
| 62 | 2 | return Html::ul($this->items, $this->options); |
|
| 63 | } |
||
| 64 | |||
| 65 | /** |
||
| 66 | * @param string $label |
||
| 67 | * @param array $options |
||
| 68 | * @return static |
||
| 69 | */ |
||
| 70 | public function item($label, $options = []) |
||
| 71 | { |
||
| 72 | 2 | $this->items[] = function ($index) use ($label, $options) { |
|
|
0 ignored issues
–
show
|
|||
| 73 | 2 | $tag = ArrayHelper::remove($options, 'tag', 'li'); |
|
| 74 | |||
| 75 | 2 | $icon = ArrayHelper::remove($options, 'icon'); |
|
| 76 | 2 | $icon = empty($icon) |
|
| 77 | 2 | ? null |
|
| 78 | 2 | : (is_string($icon) ? (string)(new Icon($icon))->li() : $icon); |
|
| 79 | |||
| 80 | 2 | $content = trim($icon . $label); |
|
| 81 | |||
| 82 | 2 | return Html::tag($tag, $content, $options); |
|
| 83 | }; |
||
| 84 | |||
| 85 | 2 | return $this; |
|
| 86 | } |
||
| 87 | |||
| 88 | /** |
||
| 89 | * @deprecated |
||
| 90 | * Change html tag. |
||
| 91 | * @param string $tag |
||
| 92 | * @return static |
||
| 93 | * @throws \yii\base\InvalidParamException |
||
| 94 | */ |
||
| 95 | 1 | public function tag($tag) |
|
| 96 | { |
||
| 97 | 1 | $this->tag = $tag; |
|
|
0 ignored issues
–
show
The property
rmrevin\yii\fontawesome\...ent\UnorderedList::$tag has been deprecated.
This property has been deprecated. The supplier of the class has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead. Loading history...
|
|||
| 98 | |||
| 99 | 1 | $this->options['tag'] = $tag; |
|
| 100 | |||
| 101 | 1 | return $this; |
|
| 102 | } |
||
| 103 | |||
| 104 | /** |
||
| 105 | * @deprecated |
||
| 106 | * @param string|null $tag |
||
| 107 | * @param array $options |
||
| 108 | * @return string |
||
| 109 | * @throws \yii\base\InvalidConfigException |
||
| 110 | */ |
||
| 111 | View Code Duplication | public function render($tag = null, $options = []) |
|
| 112 | { |
||
| 113 | $tag = empty($tag) |
||
| 114 | ? (empty($this->tag) ? static::$defaultTag : $this->tag) |
||
|
0 ignored issues
–
show
The property
rmrevin\yii\fontawesome\...ent\UnorderedList::$tag has been deprecated.
This property has been deprecated. The supplier of the class has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead. Loading history...
The property
rmrevin\yii\fontawesome\...rderedList::$defaultTag has been deprecated.
This property has been deprecated. The supplier of the class has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the property will be removed from the class and what other property to use instead. Loading history...
|
|||
| 115 | : $tag; |
||
| 116 | |||
| 117 | $options = array_merge($this->options, $options); |
||
| 118 | |||
| 119 | $items = $this->items; |
||
| 120 | |||
| 121 | return Html::tag($tag, implode($items), $options); |
||
| 122 | } |
||
| 123 | } |
||
| 124 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.