RouteActionNormalizer::normalize()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
crap 1
1
<?php
2
3
namespace Imanghafoori\HeyMan\Plugins\WatchingStrategies\Routes;
4
5
use Illuminate\Support\Str;
6
7
final class RouteActionNormalizer
8
{
9 10
    public function normalize($method, $args)
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)

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
    public function normalizeAction($actions)
15
    {
16 10
        $addNamespace = function ($action) {
17 10
            if (Str::startsWith($action, '\\')) {
18 8
                return $action;
19
            }
20
21 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

21
            return app()->/** @scrutinizer ignore-call */ getNamespace().'Http\\Controllers\\'.$action;
Loading history...
22 10
        };
23
24 10
        return array_map($addNamespace, $actions);
25
    }
26
}
27