Completed
Push — master ( e23fd6...395432 )
by Iman
05:06
created

RouteNormalizer::normalizeUrl()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 2
dl 0
loc 7
ccs 4
cts 4
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Imanghafoori\HeyMan\Normilizers;
4
5
trait RouteNormalizer
6
{
7
    /**
8
     * @param $action
9
     *
10
     * @return array
11
     */
12
    private function normalizeAction($action): array
13
    {
14 10
        $addNamespace = function ($action) {
15 10
            if ($action = ltrim($action, '\\')) {
16 10
                return $action;
17
            }
18
19
            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

19
            return app()->/** @scrutinizer ignore-call */ getNamespace().'\\Http\\Controllers\\'.$action;
Loading history...
20 10
        };
21
22 10
        return array_map($addNamespace, $this->normalizeInput($action));
0 ignored issues
show
Bug introduced by
The method normalizeInput() does not exist on Imanghafoori\HeyMan\Normilizers\RouteNormalizer. Did you maybe mean normalizeUrl()? ( Ignorable by Annotation )

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

22
        return array_map($addNamespace, $this->/** @scrutinizer ignore-call */ normalizeInput($action));

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
23
    }
24
25
    /**
26
     * @param $url
27
     * @param $verb
28
     *
29
     * @return array
30
     */
31
    private function normalizeUrl($url, $verb): array
32
    {
33 40
        $removeSlash = function ($url) use ($verb) {
34 40
            return $verb.ltrim($url, '/');
35 40
        };
36
37 40
        return array_map($removeSlash, $this->normalizeInput($url));
38
    }
39
}
40