Completed
Push — master ( 43cd61...c32de9 )
by Iman
05:22
created

Forget::__call()   A

Complexity

Conditions 6
Paths 13

Size

Total Lines 25
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 15
CRAP Score 6

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 25
ccs 15
cts 15
cp 1
rs 9.2222
c 0
b 0
f 0
cc 6
nc 13
nop 2
crap 6
1
<?php
2
3
namespace Imanghafoori\HeyMan;
4
5
use Imanghafoori\HeyMan\Normilizers\InputNormalizer;
6
use Imanghafoori\HeyMan\WatchingStrategies\Events\EventListeners;
7
use Imanghafoori\HeyMan\WatchingStrategies\Routes\RouteNormalizer;
8
use Imanghafoori\HeyMan\WatchingStrategies\Views\ViewEventListener;
9
use Imanghafoori\HeyMan\WatchingStrategies\Routes\RouteEventListener;
10
use Imanghafoori\HeyMan\WatchingStrategies\EloquentModels\EloquentEventsListener;
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
final class Forget
26
{
27
    use InputNormalizer;
28
29 14
    public function __call($method, $args)
30
    {
31 14
        $args = $this->normalizeInput($args);
32
33 14
        if (in_array($method, ['aboutRoute', 'aboutAction', 'aboutUrl'])) {
34
35 3
            $args = resolve(RouteNormalizer::class)->{'normalize'.ltrim($method, 'about')}($args);
36
37 3
            return resolve('heyman.chains')->forgetAbout(RouteEventListener::class, $args);
0 ignored issues
show
Bug introduced by
The method forgetAbout() does not exist on Illuminate\Foundation\Application. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

37
            return resolve('heyman.chains')->/** @scrutinizer ignore-call */ forgetAbout(RouteEventListener::class, $args);

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
38
        }
39
40 11
        if (in_array($method, ['aboutEvent'])) {
41 2
            resolve('heyman.chains')->forgetAbout(EventListeners::class, $args);
42
        }
43
44 11
        if (in_array($method, ['aboutView'])) {
45 4
            resolve('heyman.chains')->forgetAbout(ViewEventListener::class, $args);
46
        }
47
48 11
        if (in_array($method, ['aboutFetching', 'aboutSaving', 'aboutModel','aboutDeleting', 'aboutCreating', 'aboutUpdating'])) {
49 5
            $method = ltrim($method, 'about');
50 5
            $method = str_replace('Fetching', 'retrieved', $method);
51 5
            $method = strtolower($method);
52 5
            $method = $method == 'model' ? null : $method;
53 5
            resolve('heyman.chains')->forgetAbout(EloquentEventsListener::class, $args, $method);
54
        }
55 11
    }
56
}
57