Completed
Push — master ( 29d79e...8aac64 )
by Iman
09:16
created

Forget::aboutView()   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, RouteNormalizer};
6
use Imanghafoori\HeyMan\WatchingStrategies\{EloquentEventsManager, EventManager, RouterEventManager, ViewEventManager};
7
8
/**
9
 * Class Forget
10
 *
11
 * @method aboutRoute(array|string $routeName)
12
 * @method aboutAction(array|string $action)
13
 * @method aboutUrl(array|string $url)
14
 * @method aboutModel(array|string $model)
15
 * @method aboutDeleting(array|string $model)
16
 * @method aboutSaving(array|string $model)
17
 * @method aboutCreating(array|string $model)
18
 * @method aboutUpdating(array|string $model)
19 14
 * @method aboutFetching(array|string $model)
20
 *
21 14
 */
22
class Forget
23 4
{
24
    use InputNormalizer;
25 4
26 4
    public function aboutView(...$view)
27
    {
28 1
        resolve(ViewEventManager::class)->forgetAbout($view);
29
    }
30 1
31 1
    public function aboutEvent(...$events)
32
    {
33 2
        resolve(EventManager::class)->forgetAbout($events);
34
    }
35 2
36 2
    public function __call($method, $args)
37
    {
38 1
        $args = $this->normalizeInput($args);
39
40 1
        $method = ltrim($method, 'about');
41 1
42
        if (in_array($method, ['Route', 'Action', 'Url'])) {
43
            $args = resolve(RouteNormalizer::class)->{'normalize'.$method}($args);
44
            return resolve(RouterEventManager::class)->forgetAbout($args);
0 ignored issues
show
Bug introduced by
Are you sure the usage of resolve(Imanghafoori\Hey...ss)->forgetAbout($args) targeting Imanghafoori\HeyMan\Watc...eManager::forgetAbout() seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
45
        }
46
47
        $method = str_replace('Fetching', 'retrieved', $method);
48
        $method = strtolower($method);
49
        $method = $method == 'model' ? null : $method;
50
        resolve(EloquentEventsManager::class)->forgetAbout($args, $method);
51
    }
52
}
53