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

Forget::aboutRoute()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

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