Passed
Push — master ( 72f46d...eaab0b )
by Iman
06:11
created

Chain::__call()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 2
c 0
b 0
f 0
nc 1
nop 2
dl 0
loc 4
ccs 3
cts 3
cp 1
crap 1
rs 10
1
<?php
2
3
namespace ImanGhafoori\Terminator;
4
5
class Chain
6
{
7
    protected $data;
8
    protected $method;
9
10
    /**
11
     * Chain constructor.
12
     *
13
     * @param $args
14
     */
15 3
    public function __construct($args, $method)
16
    {
17 3
        $this->data[] = [$args, $method];
18 3
    }
19
20 1
    public function __call($method, $args)
21
    {
22 1
        $this->data[] = [$args, $method];
23 1
        return $this;
24
    }
25
26 3
    public function __destruct()
27
    {
28 3
        $resp = response();
29 3
        foreach ($this->data as $data) {
30 3
            $resp = $resp->{$data[1]}(...$data[0]);
31
        }
32 3
        respondWith($resp);
33
    }
34
}