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

EloquentSituations::hasMethod()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 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