Completed
Push — master ( 3707ab...b1ac4b )
by Iman
04:03
created

HeyMan::__construct()   A

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
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Imanghafoori\HeyMan;
4
5
use Imanghafoori\HeyMan\Hooks\EloquentHooks;
6
use Imanghafoori\HeyMan\Hooks\EventHooks;
7
use Imanghafoori\HeyMan\Hooks\RouteHooks;
8
use Imanghafoori\HeyMan\Hooks\ViewHooks;
9
10
class HeyMan
11
{
12
13
    use EloquentHooks, RouteHooks, ViewHooks, EventHooks;
14
15
    private $chain;
16
17
    /**
18
     * HeyMan constructor.
19
     *
20
     * @param \Imanghafoori\HeyMan\Chain $chain
21
     */
22 67
    public function __construct(Chain $chain)
23
    {
24 67
        $this->chain = $chain;
25 67
    }
26
27
    /**
28
     * @param $url
29
     *
30
     * @return array
31
     */
32 65
    private function normalizeInput(array $url): array
0 ignored issues
show
Unused Code introduced by
The method normalizeInput() is not used, and could be removed.

This check looks for private methods that have been defined, but are not used inside the class.

Loading history...
33
    {
34 65
        return is_array($url[0]) ? $url[0] : $url;
35
    }
36
37
    /**
38
     * @param $value
39
     *
40
     * @return YouShouldHave
41
     */
42 17
    private function authorize($value): YouShouldHave
43
    {
44 17
        $this->chain->authorizer = app(ListenerApplier::class)->init($value);
45
46 17
        return app(YouShouldHave::class);
47
    }
48
49 56
    public function startListening()
50
    {
51 56
        $callbackListener = app(ListenerFactory::class)->make();
52 56
        $this->chain->authorizer->startGuarding($callbackListener);
53 56
    }
54
}
55