Skip to content

Commit 0ccd7d6

Browse files
committed
fix(menu): update MenuHooks class
1 parent 0f03989 commit 0ccd7d6

File tree

1 file changed

+31
-30
lines changed

1 file changed

+31
-30
lines changed

src/classes/Common/Menu/MenuHooks.php

Lines changed: 31 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -4,52 +4,53 @@
44

55
namespace DoWStarterTheme\Common\Menu;
66

7-
use KepnerTregoe\Common\Contracts\Hookable;
8-
use KepnerTregoe\Common\Helpers\SVG;
9-
use KepnerTregoe\Deps\Illuminate\Support\Collection;
7+
use DoWStarterTheme\Common\Contracts\Hookable;
8+
use DoWStarterTheme\Common\Helpers\SVG;
9+
use DoWStarterTheme\Deps\Illuminate\Support\Collection;
1010
use WP_Post;
1111

1212
/**
1313
* Menu class
1414
*/
1515
class MenuHooks implements Hookable
1616
{
17-
/**
18-
* Class constructor.
19-
*
20-
* @param SVG $svg SVG helper instance.
21-
*/
17+
/**
18+
* Class constructor.
19+
*
20+
* @param SVG $svg SVG helper instance.
21+
*/
2222
public function __construct(
2323
private SVG $svg,
2424
) {
2525
}
2626

2727
/**
28-
* Adds icons to menu items.
29-
*
30-
* @filter wp_nav_menu_objects
31-
*
32-
* @param WP_Post[] $items Menu items.
33-
* @param array<string, mixed> $args object of wp_nav_menu() arguments.
34-
* @return WP_Post[] customized menu items with icons.
35-
*/
36-
public function addIcons(array $items) {
28+
* Adds icons to menu items.
29+
*
30+
* @filter wp_nav_menu_objects
31+
*
32+
* @param array<WP_Post> $items Menu items.
33+
* @return array<WP_Post> customized menu items with icons.
34+
*/
35+
public function addIcons(array $items) {
3736
return Collection::make($items)
38-
->map(function (WP_Post $item) {
39-
$icon = get_field('icon', $item);
37+
->map(
38+
function (WP_Post $item) {
39+
$icon = get_field('icon', $item);
4040

41-
if (!is_numeric($icon)) {
42-
return $item;
43-
}
41+
if (! is_numeric($icon)) {
42+
return $item;
43+
}
4444

45-
$item->title = sprintf(
46-
'%s%s',
47-
$this->svg->getAttachment($icon),
48-
$item->title
49-
);
45+
$item->title = sprintf(
46+
'%s%s',
47+
$this->svg->getAttachment($icon),
48+
$item->title
49+
);
5050

51-
return $item;
52-
})
51+
return $item;
52+
}
53+
)
5354
->all();
54-
}
55+
}
5556
}

0 commit comments

Comments
 (0)