Completed
Push — master ( 14f2a3...e42cf7 )
by Iman
10:04
created

ActionNormalizer   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 33
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A normalizeAction() 0 11 2
A normalizeUrl() 0 7 1
1
<?php
2
3
namespace Imanghafoori\HeyMan\Normilizers;
4
5
trait ActionNormalizer
6
{
7
    /**
8
     * @param $action
9
     *
10
     * @return array
11
     */
12
    private function normalizeAction($action): array
13
    {
14
        $addNamespace = function ($action) {
15
            if ($action = ltrim($action, '\\')) {
16
                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
        };
21
22
        return array_map($addNamespace, $this->normalizeInput($action));
0 ignored issues
show
Bug introduced by
The method normalizeInput() does not exist on Imanghafoori\HeyMan\Normilizers\ActionNormalizer. 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
        $removeSlash = function ($url) use ($verb) {
34
            return $verb.ltrim($url, '/');
35
        };
36
37
        return array_map($removeSlash, $this->normalizeInput($url));
38
    }
39
}