Completed
Pull Request — master (#45)
by Iman
13:28 queued 09:43
created

Forget   A

Complexity

Total Complexity 14

Size/Duplication

Total Lines 81
Duplicated Lines 0 %

Test Coverage

Coverage 85%

Importance

Changes 0
Metric Value
eloc 15
dl 0
loc 81
ccs 34
cts 40
cp 0.85
rs 10
c 0
b 0
f 0
wmc 14

14 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 2 1
A aboutFetching() 0 3 1
A aboutModel() 0 3 1
A aboutUpdating() 0 3 1
A aboutCreating() 0 3 1
A aboutUrl() 0 3 1
A aboutAction() 0 3 1
A forgetAboutModel() 0 3 1
A forgetAboutRoute() 0 3 1
A aboutSaving() 0 3 1
A aboutRoute() 0 3 1
A aboutView() 0 3 1
A aboutEvent() 0 3 1
A aboutDeleting() 0 3 1
1
<?php
2
3
namespace Imanghafoori\HeyMan;
4
5
use Imanghafoori\HeyMan\Normilizers\InputNormalizer;
6
use Imanghafoori\HeyMan\Normilizers\RouteNormalizer;
7
use Imanghafoori\HeyMan\WatchingStrategies\EloquentEventsManager;
8
use Imanghafoori\HeyMan\WatchingStrategies\EventManager;
9
use Imanghafoori\HeyMan\WatchingStrategies\RouterEventManager;
10
use Imanghafoori\HeyMan\WatchingStrategies\ViewEventManager;
11
12
class Forget
13
{
14
    use RouteNormalizer, InputNormalizer;
15
16
    /**
17
     * Forget constructor.
18
     */
19 14
    public function __construct()
20
    {
21 14
    }
22
23 4
    public function aboutView(...$view)
24
    {
25 4
        resolve(ViewEventManager::class)->forgetAbout($this->normalizeInput($view));
26 4
    }
27
28 1
    public function aboutSaving(...$model)
29
    {
30 1
        $this->forgetAboutModel($model, 'saving');
31 1
    }
32
33 2
    public function aboutDeleting(...$model)
34
    {
35 2
        $this->forgetAboutModel($model, 'deleting');
36 2
    }
37
38 1
    public function aboutFetching(...$model)
39
    {
40 1
        $this->forgetAboutModel($model, 'retrieved');
41 1
    }
42
43
    public function aboutCreating(...$model)
44
    {
45
        $this->forgetAboutModel($model, 'creating');
46
    }
47
48
    public function aboutUpdating(...$model)
49
    {
50
        $this->forgetAboutModel($model, 'updating');
51
    }
52
53 1
    public function aboutModel(...$model)
54
    {
55 1
        resolve(EloquentEventsManager::class)->forgetAbout($this->normalizeInput($model), null);
56 1
    }
57
58 2
    public function aboutEvent(...$events)
59
    {
60 2
        resolve(EventManager::class)->forgetAbout($this->normalizeInput($events));
61 2
    }
62
63 1
    public function aboutUrl(...$urls)
64
    {
65 1
        $this->forgetAboutRoute($this->normalizeUrl($urls, 'GET'));
66 1
    }
67
68 1
    public function aboutRoute(...$route)
69
    {
70 1
        $this->forgetAboutRoute($this->normalizeInput($route));
71 1
    }
72
73 1
    public function aboutAction(...$actions)
74
    {
75 1
        $this->forgetAboutRoute($this->normalizeAction($actions));
76 1
    }
77
78
    /**
79
     * @param $model
80
     * @param $event
81
     */
82 4
    private function forgetAboutModel($model, $event)
83
    {
84 4
        resolve(EloquentEventsManager::class)->forgetAbout($this->normalizeInput($model), $event);
85 4
    }
86
87
    /**
88
     * @param $normalizeUrl
89
     */
90 3
    private function forgetAboutRoute($normalizeUrl)
91
    {
92 3
        resolve(RouterEventManager::class)->forgetAbout($normalizeUrl);
93 3
    }
94
}
95