EloquentSituationProvider   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 7
eloc 16
dl 0
loc 40
ccs 16
cts 16
cp 1
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A getSituationProvider() 0 3 1
A getListener() 0 3 1
A getForgetMethods() 0 3 1
A getForgetArgs() 0 8 2
A getMethods() 0 8 1
A getForgetKey() 0 3 1
1
<?php
2
3
namespace Imanghafoori\HeyMan\Plugins\WatchingStrategies\EloquentModels;
4
5
use Imanghafoori\HeyMan\Contracts\ForgettableSituation;
6
7
class EloquentSituationProvider implements ForgettableSituation
8
{
9 121
    public function getListener()
10
    {
11 121
        return EloquentEventsListener::class;
12
    }
13
14 121
    public function getSituationProvider()
15
    {
16 121
        return EloquentSituations::class;
17
    }
18
19 121
    public function getForgetKey()
20
    {
21 121
        return 'eloquentChecks';
22
    }
23
24 14
    public static function getForgetMethods()
25
    {
26 14
        return ['aboutFetching', 'aboutSaving', 'aboutModel', 'aboutDeleting', 'aboutCreating', 'aboutUpdating'];
27
    }
28
29 5
    public static function getForgetArgs($method, $args)
30
    {
31 5
        $method = ltrim($method, 'about');
32 5
        $method = str_replace('Fetching', 'retrieved', $method);
33 5
        $method = strtolower($method);
34 5
        $method = $method == 'model' ? null : $method;
35
36 5
        return [EloquentEventsListener::class, $args, $method];
37
    }
38
39 121
    public function getMethods()
40
    {
41
        return [
42 121
            'whenYouFetch',
43
            'whenYouCreate',
44
            'whenYouUpdate',
45
            'whenYouSave',
46
            'whenYouDelete',
47
        ];
48
    }
49
}
50