Passed
Push — master ( 12242c...e9b436 )
by Iman
08:01
created

EloquentSituations   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 9
dl 0
loc 18
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __call() 0 3 1
A hasMethod() 0 3 1
1
<?php
2
3
namespace Imanghafoori\HeyMan\WatchingStrategies\EloquentModels;
4
5
use Imanghafoori\HeyMan\Situations\BaseSituation;
6
7
final class EloquentSituations extends BaseSituation
8
{
9
    const methods = [
10
        'whenYouFetch'  => 'retrieved',
11
        'whenYouCreate' => 'creating',
12
        'whenYouUpdate' => 'updating',
13
        'whenYouSave'   => 'saving',
14
        'whenYouDelete' => 'deleting',
15
    ];
16
17
    public function hasMethod($method)
18
    {
19
        return array_key_exists($method, self::methods);
20
    }
21
22
    public function __call($method, $model)
23
    {
24
        $this->setManager(EloquentEventsManager::class, $model, self::methods[$method]);
25
    }
26
}
27