Completed
Push — master ( 29d79e...8aac64 )
by Iman
09:16
created

EloquentSituations::__call()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 1

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
ccs 1
cts 1
cp 1
cc 1
nc 1
nop 2
crap 1
1
<?php
2
3
namespace Imanghafoori\HeyMan\Situations;
4
5
use Imanghafoori\HeyMan\WatchingStrategies\EloquentEventsManager;
6
7
class EloquentSituations extends BaseSituation
8
{
9
    const methods = [
10
        'whenYouFetch' => 'retrieved',
11
        'whenYouCreate' => 'creating',
12
        'whenYouUpdate' => 'updating',
13
        'whenYouSave' => 'saving',
14
        'whenYouDelete' => 'deleting',
15 5
    ];
16
17 5
    public function hasMethod($method)
18
    {
19
        return array_key_exists($method, self::methods);
20
    }
21
22
    public function __call($method, $model)
23
    {
24
        $event = self::methods[$method];
25 6
        $this->chain->eventManager = app(EloquentEventsManager::class)->init($model, $event);
0 ignored issues
show
Documentation Bug introduced by
It seems like app(Imanghafoori\HeyMan\...)->init($model, $event) of type Imanghafoori\HeyMan\Watc...s\EloquentEventsManager 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...
26
    }
27
}
28