Passed
Pull Request — master (#370)
by Valentin
04:52
created

Append::process()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 2
eloc 5
c 1
b 0
f 1
nc 2
nop 4
dl 0
loc 8
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Spiral\App\Interceptor;
6
7
use Spiral\Core\CoreInterceptorInterface;
8
use Spiral\Core\CoreInterface;
9
10
class Append implements CoreInterceptorInterface
11
{
12
    private $string;
13
14
    public function __construct(string $string)
15
    {
16
        $this->string = $string;
17
    }
18
19
    public function process(string $controller, string $action, array $parameters, CoreInterface $core): array
20
    {
21
        $result = $core->callAction($controller, $action, $parameters);
22
        if (!is_array($result)) {
23
            $result = [];
24
        }
25
        $result[] = $this->string;
26
        return $result;
27
    }
28
}
29