Completed
Push — master ( 432495...dc645f )
by Iman
04:27
created

RouteActionNormalizer   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 7
c 0
b 0
f 0
dl 0
loc 23
ccs 8
cts 8
cp 1
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A normalizeAction() 0 11 2
A normalize() 0 3 1
1
<?php
2
3
namespace Imanghafoori\HeyMan\WatchingStrategies\Routes;
4
5
use Illuminate\Support\Str;
6
7
final class RouteActionNormalizer
8
{
9 10
    public function normalize($method, $args): array
0 ignored issues
show
Unused Code introduced by
The parameter $method is not used and could be removed. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-unused  annotation

9
    public function normalize(/** @scrutinizer ignore-unused */ $method, $args): array

This check looks for parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
10
    {
11 10
        return [$this->normalizeAction($args)];
12
    }
13
14
    /**
15
     * @param $actions
16
     *
17
     * @return array
18
     */
19
    public function normalizeAction($actions): array
20
    {
21 10
        $addNamespace = function ($action) {
22 10
            if (Str::startsWith($action, '\\')) {
23 8
                return $action;
24
            }
25
26 2
            return app()->getNamespace().'Http\\Controllers\\'.$action;
0 ignored issues
show
introduced by
The method getNamespace() does not exist on Illuminate\Container\Container. Are you sure you never get this type here, but always one of the subclasses? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

26
            return app()->/** @scrutinizer ignore-call */ getNamespace().'Http\\Controllers\\'.$action;
Loading history...
27 10
        };
28
29 10
        return array_map($addNamespace, $actions);
30
    }
31
}
32