Completed
Pull Request — master (#47)
by Iman
13:15 queued 09:06
created

Forget   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 5
eloc 13
dl 0
loc 30
ccs 16
cts 16
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A aboutView() 0 3 1
A __call() 0 16 3
A aboutEvent() 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
/**
13
 * Class Forget.
14
 *
15
 * @method aboutRoute(array|string $routeName)
16
 * @method aboutAction(array|string $action)
17
 * @method aboutUrl(array|string $url)
18
 * @method aboutModel(array|string $model)
19
 * @method aboutDeleting(array|string $model)
20
 * @method aboutSaving(array|string $model)
21
 * @method aboutCreating(array|string $model)
22
 * @method aboutUpdating(array|string $model)
23
 * @method aboutFetching(array|string $model)
24
 */
25
class Forget
26
{
27
    use InputNormalizer;
28
29 4
    public function aboutView(...$view)
30
    {
31 4
        resolve(ViewEventManager::class)->forgetAbout($view);
32 4
    }
33
34 2
    public function aboutEvent(...$events)
35
    {
36 2
        resolve(EventManager::class)->forgetAbout($events);
37 2
    }
38
39 8
    public function __call($method, $args)
40
    {
41 8
        $args = $this->normalizeInput($args);
42
43 8
        $method = ltrim($method, 'about');
44
45 8
        if (in_array($method, ['Route', 'Action', 'Url'])) {
46 3
            $args = resolve(RouteNormalizer::class)->{'normalize'.$method}($args);
47
48 3
            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...
49
        }
50
51 5
        $method = str_replace('Fetching', 'retrieved', $method);
52 5
        $method = strtolower($method);
53 5
        $method = $method == 'model' ? null : $method;
54 5
        resolve(EloquentEventsManager::class)->forgetAbout($args, $method);
55 5
    }
56
}
57