Skip to content

Commit

Permalink
increased php version requirement to 8.0
Browse files Browse the repository at this point in the history
  • Loading branch information
denisdulici committed Oct 25, 2022
1 parent 1bad5f9 commit 2247446
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 89 deletions.
9 changes: 0 additions & 9 deletions .scrutinizer.yml

This file was deleted.

5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
![Downloads](https://img.shields.io/packagist/dt/akaunting/laravel-menu)
![Tests](https://img.shields.io/github/workflow/status/akaunting/laravel-menu/Tests?label=tests)
[![StyleCI](https://github.styleci.io/repos/180763610/shield?style=flat&branch=master)](https://styleci.io/repos/180763610)
[![Quality](https://img.shields.io/scrutinizer/quality/g/akaunting/laravel-menu?label=quality)](https://scrutinizer-ci.com/g/akaunting/laravel-menu)
[![License](https://img.shields.io/github/license/akaunting/laravel-menu)](LICENSE.md)

This package intends to create and manage menus and sidebars for your Laravel app. It ships with ready-to-go presenters and you can create your own ones.
Expand Down Expand Up @@ -51,6 +50,10 @@ Please see [Releases](../../releases) for more information what has changed rece

Pull requests are more than welcome. You must follow the PSR coding standards.

## Security

Please review [our security policy](https://github.com/akaunting/laravel-menu/security/policy) on how to report security vulnerabilities.

## Credits

- [Denis Duliçi](https://github.com/denisdulici)
Expand Down
7 changes: 7 additions & 0 deletions SECURITY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Security Policy

**PLEASE DON'T DISCLOSE SECURITY-RELATED ISSUES PUBLICLY, [SEE BELOW](#reporting-a-vulnerability).**

## Reporting a Vulnerability

If you discover any security related issues, please email [email protected] instead of using the issue tracker.
18 changes: 9 additions & 9 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@
}
],
"require": {
"php": ">=7.3",
"illuminate/config": ">=5.5",
"illuminate/support": ">=5.5",
"illuminate/view": ">=5.5",
"laravelcollective/html": ">=5.5"
"php": "^8.0",
"illuminate/config": "^9.0",
"illuminate/support": "^9.0",
"illuminate/view": "^9.0",
"laravelcollective/html": "^6.3"
},
"require-dev": {
"friendsofphp/php-cs-fixer": ">=3.4",
"mockery/mockery": ">=1.4",
"orchestra/testbench": ">=6.0",
"phpunit/phpunit": ">=9.0"
"friendsofphp/php-cs-fixer": "^3.12",
"mockery/mockery": "^1.5",
"orchestra/testbench": "^7.11",
"phpunit/phpunit": "^9.5"
},
"autoload": {
"psr-4": {
Expand Down
84 changes: 16 additions & 68 deletions src/Menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,20 @@

namespace Akaunting\Menu;

use Akaunting\Menu\MenuBuilder;
use Closure;
use Countable;
use Illuminate\Contracts\Config\Repository;
use Illuminate\View\Factory;

class Menu implements Countable
{
/**
* The menu collections.
*
* @var array
*/
protected $menu = [];
/**
* @var Repository
*/
private $config;
/**
* @var Factory
*/
private $views;
protected array $menu = [];

protected Repository $config;

protected Factory $views;

/**
* The constructor.
*
* @param Factory $views
* @param Repository $config
*/
public function __construct(Factory $views, Repository $config)
{
$this->views = $views;
Expand All @@ -38,26 +24,16 @@ public function __construct(Factory $views, Repository $config)

/**
* Make new menu.
*
* @param string $name
* @param Closure $callback
*
* @return \Akaunting\Menu\MenuBuilder
*/
public function make($name, \Closure $callback)
public function make(string $name, Closure $callback): mixed
{
return $this->create($name, $callback);
}

/**
* Create new menu.
*
* @param string $name
* @param Callable $resolver
*
* @return \Akaunting\Menu\MenuBuilder
*/
public function create($name, Closure $resolver)
public function create(string $name, Closure $resolver): mixed
{
$builder = new MenuBuilder($name, $this->config);

Expand All @@ -70,36 +46,24 @@ public function create($name, Closure $resolver)

/**
* Check if the menu exists.
*
* @param string $name
*
* @return bool
*/
public function has($name)
public function has(string $name): bool
{
return array_key_exists($name, $this->menu);
}

/**
* Get instance of the given menu if exists.
*
* @param string $name
*
* @return string|null
*/
public function instance($name)
public function instance(string $name): ?MenuBuilder
{
return $this->has($name) ? $this->menu[$name] : null;
}

/**
* Modify a specific menu.
*
* @param string $name
* @param Closure $callback
* @return void
*/
public function modify($name, Closure $callback)
public function modify(string $name, Closure $callback): void
{
$menu = collect($this->menu)->filter(function ($menu) use ($name) {
return $menu->getName() == $name;
Expand All @@ -110,55 +74,39 @@ public function modify($name, Closure $callback)

/**
* Render the menu tag by given name.
*
* @param string $name
* @param string $presenter
*
* @return string|null
*/
public function get($name, $presenter = null, $bindings = [])
public function get(string $name, ?string $presenter = null, array $bindings = []): ?string
{
return $this->has($name) ?
$this->menu[$name]->setBindings($bindings)->render($presenter) : null;
}

/**
* Render the menu tag by given name.
*
* @param $name
* @param null $presenter
*
* @return string
*/
public function render($name, $presenter = null, $bindings = [])
public function render(string $name, ?string $presenter = null, array $bindings = []): ?string
{
return $this->get($name, $presenter, $bindings);
}

/**
* Get a stylesheet for enable multilevel menu.
*
* @return mixed
*/
public function style()
public function style(): mixed
{
return $this->views->make('menu::bootstrap3.style')->render();
}

/**
* Get all menus.
*
* @return array
*/
public function all()
public function all(): array
{
return $this->menu;
}

/**
* Count menus.
*
* @return int
*/
public function count(): int
{
Expand All @@ -168,7 +116,7 @@ public function count(): int
/**
* Empty the current menus.
*/
public function destroy()
public function destroy(): void
{
$this->menu = [];
}
Expand Down
4 changes: 2 additions & 2 deletions src/MenuItem.php
Original file line number Diff line number Diff line change
Expand Up @@ -576,7 +576,7 @@ protected function hasRoute()
protected function getActiveStateFromRoute()
{
$url = str_replace(url('/') . '/', '', $this->getUrl());
$url = str_replace('#' . $this->fragment, '', $url);
$url = str_replace('#' . (string) $this->fragment, '', $url);

return $this->checkActiveState($url);
}
Expand All @@ -588,7 +588,7 @@ protected function getActiveStateFromRoute()
*/
protected function getActiveStateFromUrl()
{
$url = str_replace('#' . $this->fragment, '', $this->url);
$url = str_replace('#' . (string) $this->fragment, '', (string) $this->url);

return $this->checkActiveState($url);
}
Expand Down

0 comments on commit 2247446

Please sign in to comment.