| Total Complexity | 7 |
| Total Lines | 58 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 0 | ||
| 1 | <?php |
||
| 7 | class Routes implements IRoutes |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * route list as array |
||
| 11 | * |
||
| 12 | * @var array |
||
| 13 | */ |
||
| 14 | private $routes = []; |
||
| 15 | |||
| 16 | /** |
||
| 17 | * __construct |
||
| 18 | * |
||
| 19 | * @param array $routes |
||
| 20 | * @return Routes |
||
| 21 | */ |
||
| 22 | 4 | public function __construct(array $routes = []) |
|
| 23 | { |
||
| 24 | 4 | if (!empty($routes)) { |
|
| 25 | 4 | $this->set($routes); |
|
| 26 | } |
||
| 27 | 4 | return $this; |
|
| 28 | } |
||
| 29 | |||
| 30 | /** |
||
| 31 | * returns routes as array |
||
| 32 | * |
||
| 33 | * @return array |
||
| 34 | */ |
||
| 35 | 2 | public function get(): array |
|
| 36 | { |
||
| 37 | 2 | return $this->routes; |
|
| 38 | } |
||
| 39 | |||
| 40 | /** |
||
| 41 | * set routes as array and returns Routes |
||
| 42 | * |
||
| 43 | * @param array $routes |
||
| 44 | * @return Routes |
||
| 45 | */ |
||
| 46 | 4 | public function set(array $routes): Routes |
|
| 47 | { |
||
| 48 | 4 | $this->routes = $routes; |
|
| 49 | 4 | $this->validate(); |
|
| 50 | 4 | return $this; |
|
| 51 | } |
||
| 52 | |||
| 53 | /** |
||
| 54 | * validate routes to be an array of regexp string |
||
| 55 | * |
||
| 56 | * @throws Exception |
||
| 57 | */ |
||
| 58 | 2 | protected function validate() |
|
| 65 | } |
||
| 66 | } |
||
| 67 | } |
||
| 68 | } |
||
| 69 |