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

EloquentSituations   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
eloc 10
dl 0
loc 19
rs 10
c 0
b 0
f 0
ccs 3
cts 3
cp 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A hasMethod() 0 3 1
A __call() 0 4 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