Skip to content

Commit

Permalink
CS fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jeroennoten committed Aug 28, 2016
1 parent 1c55f1a commit c45c5e5
Show file tree
Hide file tree
Showing 9 changed files with 25 additions and 41 deletions.
11 changes: 5 additions & 6 deletions src/AdminLte.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ public function __construct(
ActiveChecker $activeChecker,
Gate $gate
) {
$this->events = $events;
$this->urlGenerator = $urlGenerator;
$this->events = $events;
$this->urlGenerator = $urlGenerator;
$this->activeChecker = $activeChecker;
$this->gate = $gate;
$this->gate = $gate;
}

public function menu()
{
if ( ! $this->menu) {
if (! $this->menu) {
$this->menu = $this->buildMenu();
}

Expand All @@ -44,8 +44,7 @@ public function menu()

protected function buildMenu()
{
$builder = new Builder($this->urlGenerator, $this->activeChecker,
$this->gate);
$builder = new Builder($this->urlGenerator, $this->activeChecker, $this->gate);

$this->events->fire(new BuildingMenu($builder));

Expand Down
6 changes: 3 additions & 3 deletions src/Menu/ActiveChecker.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,15 @@ public function __construct(Request $request)

public function isActive($item)
{
if (isset( $item['active'] )) {
if (isset($item['active'])) {
return $this->isExplicitActive($item['active']);
}

if (isset( $item['submenu'] )) {
if (isset($item['submenu'])) {
return $this->containsActive($item['submenu']);
}

if (isset( $item['url'] )) {
if (isset($item['url'])) {
return $this->isActiveUrl($item['url']);
}

Expand Down
26 changes: 13 additions & 13 deletions src/Menu/Builder.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ public function __construct(
ActiveChecker $activeChecker,
Gate $gate
) {
$this->urlGenerator = $urlGenerator;
$this->urlGenerator = $urlGenerator;
$this->activeChecker = $activeChecker;
$this->gate = $gate;
$this->gate = $gate;
}

public function add()
Expand All @@ -44,7 +44,7 @@ protected function transformItems($items)

protected function isVisible($item)
{
return ! isset( $item['can'] ) || $this->gate->allows($item['can']);
return ! isset($item['can']) || $this->gate->allows($item['can']);
}

protected function transformItem($item)
Expand All @@ -53,27 +53,27 @@ protected function transformItem($item)
return $item;
}

$item['href'] = $this->makeHref($item);
$item['href'] = $this->makeHref($item);
$item['active'] = $this->isActive($item);

if (isset( $item['submenu'] )) {
$item['submenu'] = $this->transformItems($item['submenu']);
$item['submenu_open'] = $item['active'];
if (isset($item['submenu'])) {
$item['submenu'] = $this->transformItems($item['submenu']);
$item['submenu_open'] = $item['active'];
$item['submenu_classes'] = $this->makeSubmenuClasses($item);
$item['submenu_class'] = implode(' ', $item['submenu_classes']);
$item['submenu_class'] = implode(' ', $item['submenu_classes']);
}

$item['classes'] = $this->makeClasses($item);
$item['class'] = implode(' ', $item['classes']);
$item['classes'] = $this->makeClasses($item);
$item['class'] = implode(' ', $item['classes']);
$item['top_nav_classes'] = $this->makeClasses($item, true);
$item['top_nav_class'] = implode(' ', $item['top_nav_classes']);
$item['top_nav_class'] = implode(' ', $item['top_nav_classes']);

return $item;
}

protected function makeHref($item)
{
if ( ! isset( $item['url'] )) {
if (! isset($item['url'])) {
return '#';
}

Expand All @@ -88,7 +88,7 @@ protected function makeClasses($item, $topNav = false)
$classes[] = 'active';
}

if (isset( $item['submenu'] )) {
if (isset($item['submenu'])) {
$classes[] = $topNav ? 'dropdown' : 'treeview';
}

Expand Down
5 changes: 1 addition & 4 deletions src/ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@

class ServiceProvider extends BaseServiceProvider
{

public function register()
{
//
Expand Down Expand Up @@ -97,7 +96,6 @@ private function publishAssets()
private function packagePath($path)
{
return __DIR__."/../$path";

}

private function registerCommands()
Expand All @@ -119,9 +117,8 @@ public static function registerMenu(Dispatcher $events, Repository $config)
BuildingMenu::class,
function (BuildingMenu $event) use ($config) {
$menu = $config->get('adminlte.menu');
call_user_func_array([ $event->menu, 'add' ], $menu);
call_user_func_array([$event->menu, 'add'], $menu);
}
);
}

}
2 changes: 0 additions & 2 deletions tests/AdminLteTest.php
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
<?php

use JeroenNoten\LaravelAdminLte\Events\BuildingMenu;
use Illuminate\Auth\Access\Gate;
use Illuminate\Foundation\Application as App;

class AdminLteTest extends TestCase
{
Expand Down
1 change: 0 additions & 1 deletion tests/Menu/ActiveCheckerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -90,5 +90,4 @@ public function testExplicitActiveRegex()

$this->assertTrue($isActive);
}

}
1 change: 0 additions & 1 deletion tests/Menu/BuilderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -218,5 +218,4 @@ function () {
$this->assertCount(1, $builder->menu);
$this->assertEquals('About', $builder->menu[0]['text']);
}

}
1 change: 0 additions & 1 deletion tests/ServiceProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
use Illuminate\Config\Repository;
use Illuminate\Events\Dispatcher;
use JeroenNoten\LaravelAdminLte\Events\BuildingMenu;
use JeroenNoten\LaravelAdminLte\Menu\Builder;
use JeroenNoten\LaravelAdminLte\ServiceProvider;

class ServiceProviderTest extends TestCase
Expand Down
13 changes: 3 additions & 10 deletions tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,7 @@ protected function makeMenuBuilder(
$uri = 'http://example.com',
GateContract $gate = null
) {
return new Builder(
$this->makeUrlGenerator($uri),
$this->makeActiveChecker($uri),
$gate ?: $this->makeGate()
);
return new Builder($this->makeUrlGenerator($uri), $this->makeActiveChecker($uri), $gate ?: $this->makeGate());
}

protected function makeActiveChecker($uri = 'http://example.com')
Expand All @@ -40,10 +36,7 @@ private function makeRequest($uri)
protected function makeAdminLte()
{
return new AdminLte(
$this->getDispatcher(),
$this->makeUrlGenerator(),
$this->makeActiveChecker(),
$this->makeGate()
$this->getDispatcher(), $this->makeUrlGenerator(), $this->makeActiveChecker(), $this->makeGate()
);
}

Expand All @@ -70,7 +63,7 @@ protected function makeContainer()

protected function getDispatcher()
{
if ( ! $this->dispatcher) {
if (! $this->dispatcher) {
$this->dispatcher = new Dispatcher;
}

Expand Down

0 comments on commit c45c5e5

Please sign in to comment.