ControllerTrait::init()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 0

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
cc 1
eloc 0
c 2
b 1
f 0
nc 1
nop 0
dl 0
loc 2
rs 10
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