Chain::__destruct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2.032

Importance

Changes 1
Bugs 1 Features 0
Metric Value
cc 2
eloc 4
c 1
b 1
f 0
nc 2
nop 0
dl 0
loc 7
ccs 4
cts 5
cp 0.8
crap 2.032
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
24
        return $this;
25
    }
26 3
27
    public function __destruct()
28 3
    {
29 3
        $resp = response();
30 3
        foreach ($this->data as $data) {
31
            $resp = $resp->{$data[1]}(...$data[0]);
32 3
        }
33
        respondWith($resp);
34
    }
35
}
36