Passed
Push — master ( bea9fb...617266 )
by Siim
11:02
created

AvailableRoutesTrait::addAvailableRoutes()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 2
nc 2
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: siim
5
 * Date: 4.02.19
6
 * Time: 11:09
7
 */
8
9
namespace Sf4\Api\RequestHandler\Traits;
10
11
trait AvailableRoutesTrait
12
{
13
14
    /** @var array $availableRoutes */
15
    protected $availableRoutes = [];
16
17
    /**
18
     * @return array
19
     */
20
    public function getAvailableRoutes(): array
21
    {
22
        return $this->availableRoutes;
23
    }
24
25
    /**
26
     * @param array $availableRoutes
27
     */
28
    public function setAvailableRoutes(array $availableRoutes)
29
    {
30
        $this->availableRoutes = $availableRoutes;
31
    }
32
33
    /**
34
     * @param array $availableRoutes
35
     */
36
    public function addAvailableRoutes(array $availableRoutes)
37
    {
38
        foreach ($availableRoutes as $route => $requestClass) {
39
            $this->addAvailableRoute($route, $requestClass);
40
        }
41
    }
42
43
    /**
44
     * @param string $route
45
     * @param string $requestClass
46
     */
47
    public function addAvailableRoute(string $route, string $requestClass)
48
    {
49
        if (!in_array($route, $this->availableRoutes)) {
50
            $this->availableRoutes[$route] = $requestClass;
51
        }
52
    }
53
}
54