Completed
Push — master ( 7989d2...c7d3e4 )
by ARCANEDEV
12s queued 11s
created

RouteViewerRoutes::getRouteAttributes()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Arcanedev\RouteViewer\Http\Routes;
6
7
use Arcanedev\Support\Routing\RouteRegistrar;
8
9
/**
10
 * Class     RouteViewerRoutes
11
 *
12
 * @package  Arcanedev\RouteViewer\Http\Routes
13
 * @author   ARCANEDEV <[email protected]>
14
 */
15
class RouteViewerRoutes extends RouteRegistrar
16
{
17
    /* -----------------------------------------------------------------
18
     |  Main Methods
19
     | -----------------------------------------------------------------
20
     */
21
22
    /**
23
     * Map routes.
24
     */
25 72
    public function map(): void
26
    {
27
        $this->group($this->getRouteAttributes(), function () {
0 ignored issues
show
Documentation Bug introduced by
The method group does not exist on object<Arcanedev\RouteVi...utes\RouteViewerRoutes>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
28 72
            $this->get('/', 'RouteViewerController@index')
0 ignored issues
show
Documentation Bug introduced by
The method get does not exist on object<Arcanedev\RouteVi...utes\RouteViewerRoutes>? Since you implemented __call, maybe consider adding a @method annotation.

If you implement __call and you know which methods are available, you can improve IDE auto-completion and static analysis by adding a @method annotation to the class.

This is often the case, when __call is implemented by a parent class and only the child class knows which methods exist:

class ParentClass {
    private $data = array();

    public function __call($method, array $args) {
        if (0 === strpos($method, 'get')) {
            return $this->data[strtolower(substr($method, 3))];
        }

        throw new \LogicException(sprintf('Unsupported method: %s', $method));
    }
}

/**
 * If this class knows which fields exist, you can specify the methods here:
 *
 * @method string getName()
 */
class SomeClass extends ParentClass { }
Loading history...
29 72
                 ->name('index'); // route-viewer::index
30 72
        });
31 72
    }
32
33
    /* -----------------------------------------------------------------
34
     |  Other Methods
35
     | -----------------------------------------------------------------
36
     */
37
38
    /**
39
     * Get the route attributes.
40
     *
41
     * @return array
42
     */
43 72
    private function getRouteAttributes(): array
44
    {
45 72
        return config('route-viewer.route.attributes', [
46 72
            'prefix'     => 'route-viewer',
47
            'as'         => 'route-viewer::',
48
            'namespace'  => 'Arcanedev\\RouteViewer\\Http\\Controllers',
49
        ]);
50
    }
51
}
52