Completed
Push — master ( a05b58...c7a28f )
by Iman
05:22
created

HeyMan::mapping()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 5
ccs 0
cts 0
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Imanghafoori\HeyMan;
4
5
use Imanghafoori\HeyMan\Hooks\EloquentHooks;
6
use Imanghafoori\HeyMan\Hooks\EventHooks;
7
use Imanghafoori\HeyMan\Hooks\ViewHooks;
0 ignored issues
show
Bug introduced by
The type Imanghafoori\HeyMan\Hooks\ViewHooks was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
8
use Imanghafoori\HeyMan\Normilizers\InputNormalizer;
9
use Imanghafoori\HeyMan\Situations\RouteSituations;
10
use Imanghafoori\HeyMan\Situations\ViewSituations;
11
12
class HeyMan
13
{
14
    use EloquentHooks, EventHooks, InputNormalizer;
15
16
    private $chain;
17
18
    /**
19
     * HeyMan constructor.
20
     *
21
     * @param Chain $chain
22
     */
23 102
    public function __construct(Chain $chain)
24
    {
25 102
        $this->chain = $chain;
26 102
    }
27
28 15
    public function turnOff(): Consider
29
    {
30 15
        return new Consider('turnOff');
31
    }
32
33 1
    public function turnOn(): Consider
34
    {
35 1
        return new Consider('turnOn');
36
    }
37
38 13
    public function forget(): Forget
39
    {
40 13
        return new Forget();
41
    }
42
43 58
    public function __call($method, $args)
44
    {
45 58
        foreach ($this->mapping() as $className => $methods) {
46 58
            if (str_contains($method, $methods)) {
47
                return app($className)->$method(...$args);
48
            }
49
        }
50
    }
51
52
    /**
53
     * @return array
54
     */
55
    private function mapping(): array
56
    {
57
        return [
58
            RouteSituations::class => ['Send', 'Url', 'Route', 'Action'],
59
            ViewSituations::class => ['View'],
60
        ];
61
    }
62
}
63