Passed
Push — master ( 1719b8...ef9411 )
by Iman
02:43
created

ViewHooks::whenYouViewBlade()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Imanghafoori\HeyMan\Hooks;
4
5
trait ViewHooks
6
{
7
    /**
8
     * @param array|string $views
9
     * @return \Imanghafoori\HeyMan\YouShouldHave
10
     */
11
    public function whenYouSeeViewFile(...$views)
12
    {
13
        $views = $this->normalizeView($views);
14
        return $this->authorize($views);
0 ignored issues
show
Bug introduced by
It seems like authorize() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

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

14
        return $this->/** @scrutinizer ignore-call */ authorize($views);
Loading history...
15
    }
16
17
    /**
18
     * @param array|string $views
19
     * @return \Imanghafoori\HeyMan\YouShouldHave
20
     */
21
    public function whenYouViewBlade(...$views)
22
    {
23
        return $this->whenYouSeeViewFile(...$views);
24
    }
25
26
    /**
27
     * @param $views
28
     * @return array
29
     */
30
    private function normalizeView(array $views): array
31
    {
32
        $views = $this->normalizeInput($views);
0 ignored issues
show
Bug introduced by
The method normalizeInput() does not exist on Imanghafoori\HeyMan\Hooks\ViewHooks. Did you maybe mean normalizeView()? ( Ignorable by Annotation )

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

32
        /** @scrutinizer ignore-call */ 
33
        $views = $this->normalizeInput($views);

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...
33
        $mapper = function ($view) {
34
            return 'creating: '.$view;
35
        };
36
37
        return array_map($mapper, $views);
38
    }
39
}