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

HeyMan   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 43
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 43
ccs 11
cts 11
cp 1
rs 10
c 0
b 0
f 0
wmc 5

4 Methods

Rating   Name   Duplication   Size   Complexity  
A authorize() 0 5 1
A normalizeInput() 0 3 2
A __construct() 0 3 1
A startListening() 0 4 1
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