Passed
Push — master ( 2ef3c3...2a4402 )
by Iman
03:41
created

EventHooks::watchEvents()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 5
ccs 3
cts 3
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Imanghafoori\HeyMan\Hooks;
4
5
use Imanghafoori\HeyMan\WatchingStrategies\EventManager;
6
use Imanghafoori\HeyMan\YouShouldHave;
7
8
trait EventHooks
9
{
10
    /**
11
     * @param mixed ...$event
12
     *
13
     * @return YouShouldHave
14
     */
15 10
    public function whenEventHappens(...$event): YouShouldHave
16
    {
17 10
        return $this->watchEvents($this->normalizeInput($event));
0 ignored issues
show
Bug introduced by
It seems like normalizeInput() 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

17
        return $this->watchEvents($this->/** @scrutinizer ignore-call */ normalizeInput($event));
Loading history...
18
    }
19
20
    /**
21
     * @param $eventName
22
     *
23
     * @return YouShouldHave
24
     */
25 10
    private function watchEvents($eventName): YouShouldHave
26
    {
27 10
        $this->chain->eventManager = app(EventManager::class)->init($eventName);
28
29 10
        return app(YouShouldHave::class);
30
    }
31
}
32