Chain   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Test Coverage

Coverage 91.67%

Importance

Changes 2
Bugs 2 Features 0
Metric Value
eloc 10
c 2
b 2
f 0
dl 0
loc 29
ccs 11
cts 12
cp 0.9167
rs 10
wmc 4

3 Methods

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