Completed
Push — master ( 095584...b95a45 )
by Iman
04:31
created

HeyMan   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Test Coverage

Coverage 83.33%

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 46
ccs 10
cts 12
cp 0.8333
rs 10
c 0
b 0
f 0
wmc 6

5 Methods

Rating   Name   Duplication   Size   Complexity  
A normalizeInput() 0 3 2
A __construct() 0 3 1
A holdWhen() 0 5 1
A turnOn() 0 3 1
A turnOff() 0 3 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
use Imanghafoori\HeyMan\WatchingStrategies\BasicEventManager;
10
11
class HeyMan
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 77
    public function __construct(Chain $chain)
23
    {
24 77
        $this->chain = $chain;
25 77
    }
26
27
    /**
28
     * @param $url
29
     *
30
     * @return array
31
     */
32 77
    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 77
        return is_array($url[0]) ? $url[0] : $url;
35
    }
36
37
    /**
38
     * @param $eventName
39
     *
40
     * @return YouShouldHave
41
     */
42 5
    private function holdWhen($eventName): YouShouldHave
0 ignored issues
show
Unused Code introduced by
The method holdWhen() 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...
43
    {
44 5
        $this->chain->eventManager = app(BasicEventManager::class)->init($eventName);
0 ignored issues
show
Documentation Bug introduced by
It seems like app(Imanghafoori\HeyMan\...lass)->init($eventName) of type Imanghafoori\HeyMan\Watc...egies\BasicEventManager is incompatible with the declared type Imanghafoori\HeyMan\ListenerApplier of property $eventManager.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
45
46 5
        return app(YouShouldHave::class);
47
    }
48
49 11
    public function turnOff(): Consider
50
    {
51 11
        return new Consider('turnOff');
52
    }
53
54
    public function turnOn(): Consider
55
    {
56
        return new Consider('turnOn');
57
    }
58
}
59