ControllerTrait   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
wmc 2
eloc 4
c 2
b 1
f 0
dl 0
loc 25
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setupPaths() 0 5 1
A init() 0 2 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace ParcelValue\ApiClient\Traits;
6
7
trait ControllerTrait
8
{
9
    abstract protected function request(): \WebServCo\Framework\Interfaces\RequestInterface;
10
11
    /**
12
     * @param mixed $key Can be an array, a string,
13
     *                          or a special formatted string
14
     *                          (eg 'i18n/lang').
15
     * @param mixed $value The value to be stored.
16
     * @return bool True on success and false on failure.
17
     */
18
    abstract protected function setData($key, $value): bool;
19
20
    protected function setupPaths(): void
21
    {
22
        $this->setData('url/app', $this->request()->getAppUrl());
23
        $this->setData('url/lang', $this->request()->getUrl(['lang']));
24
        $this->setData('url/current', $this->request()->getUrl());
25
    }
26
27
    /**
28
     * Called (optionally) by each method.
29
     */
30
    protected function init(): void
31
    {
32
        // No content
33
    }
34
}
35