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

AvailableRoutesTrait   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 40
rs 10
c 0
b 0
f 0
wmc 6

4 Methods

Rating   Name   Duplication   Size   Complexity  
A setAvailableRoutes() 0 3 1
A getAvailableRoutes() 0 3 1
A addAvailableRoutes() 0 4 2
A addAvailableRoute() 0 4 2
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