Skip to content

Commit 2b3b9bc

Browse files
committed
misc cleanup
1 parent 1b0aca3 commit 2b3b9bc

7 files changed

+28
-6
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/.idea
12
/vendor
23
composer.phar
34
composer.lock

src/AbstractItem.php

+2-1
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,10 @@ public static function addIconResolvers(array $resolvers)
7777
*/
7878
protected function parseAttributes(array $in)
7979
{
80-
if (isset($in['icon']) && $in['icon'] instanceof Icon\IconInterface) {
80+
if (isset($in['icon']) && $in['icon'] instanceof Icons\IconInterface) {
8181
$this->icon = $in['icon'];
8282
} else {
83+
/** @var Icons\IconInterface $resolver */
8384
foreach (static::$iconResolvers as $key => $resolver) {
8485
if (array_key_exists($key, $in)) {
8586
$this->icon = $resolver::createFromAttribute($in[$key]);

src/Collection.php

+4-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class Collection
2222
/**
2323
* The menu items.
2424
*
25-
* @var array
25+
* @var ItemInterface[]
2626
*/
2727
protected $items = [];
2828

@@ -246,10 +246,13 @@ public function render()
246246
$items = '';
247247
$sorted = $this->items;
248248
ksort($sorted);
249+
250+
/** @var ItemInterface $item */
249251
foreach (array_flatten($sorted) as $item) {
250252
if ($item === static::DIVIDER) $items .= '<li class="divider"></li>';
251253
else $items .= '<li>'.$item->render().'</li>';
252254
}
255+
253256
return '<ul '.$this->renderAttributes().'>'.$items.'</ul>';
254257
}
255258
}

src/Icons/FontAwesomeStack.php

+7
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,14 @@
1111

1212
class FontAwesomeStack implements IconInterface
1313
{
14+
/**
15+
* @var IconInterface[]
16+
*/
1417
protected $icons;
18+
19+
/**
20+
* @var string[]
21+
*/
1522
protected $classes = ['stack'];
1623

1724
public function __construct(array $icons, array $classes = array())

src/ItemInterface.php

+12
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,17 @@
1111

1212
interface ItemInterface
1313
{
14+
/**
15+
* Render the item.
16+
*
17+
* @return string
18+
*/
1419
public function render();
20+
21+
/**
22+
* Get the unique ID string for the item.
23+
*
24+
* @return string
25+
*/
26+
public function getId();
1527
}

src/SubmenuItem.php

-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@
99

1010
namespace anlutro\Menu;
1111

12-
use Illuminate\Support\Str;
13-
1412
/**
1513
* A menu submenu item.
1614
*/

tests/MenuItemTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,14 @@ public function testCustomIconResolver()
5151
}
5252
}
5353

54-
class CustomIcon implements \anlutro\Menu\ItemInterface
54+
class CustomIcon implements \anlutro\Menu\Icons\IconInterface
5555
{
5656
public function render()
5757
{
5858
return 'custom-icon';
5959
}
6060

61-
public static function createFromAttribute()
61+
public static function createFromAttribute($attribute)
6262
{
6363
return new static;
6464
}

0 commit comments

Comments
 (0)