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

Chain   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 10
c 0
b 0
f 0
dl 0
loc 28
ccs 11
cts 11
cp 1
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __destruct() 0 7 2
A __construct() 0 3 1
A __call() 0 4 1
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
}