Completed
Pull Request — master (#38)
by Iman
09:50 queued 07:06
created

HeyMan::__call()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 3.576

Importance

Changes 0
Metric Value
cc 3
eloc 4
nc 3
nop 2
dl 0
loc 6
ccs 3
cts 5
cp 0.6
crap 3.576
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;
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, ViewHooks, 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
        if (str_contains($method, ['Send', 'Url', 'Route', 'Action'])) {
46 58
            return app(RouteSituations::class)->$method(...$args);
47
        } elseif (str_contains($method, ['View'])) {
48
            return app(ViewSituations::class)->$method(...$args);
49
        }
50
    }
51
}
52