YamlRouteProvider   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 3
dl 0
loc 18
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 2
1
<?php
2
3
namespace MatthiasMullie\Api\Routes\Providers;
4
5
use Symfony\Component\Yaml\Yaml;
6
7
/**
8
 * @author Matthias Mullie <[email protected]>
9
 * @copyright Copyright (c) 2016, Matthias Mullie. All rights reserved
10
 * @license LICENSE MIT
11
 */
12
class YamlRouteProvider extends ArrayRouteProvider implements RouteProviderInterface
13
{
14
    /**
15
     * @param string $path Path to route data
16
     *
17
     * @throws Exception
18
     */
19
    public function __construct(string $path)
20
    {
21
        if (!class_exists('Symfony\Component\Yaml\Yaml')) {
22
            throw new Exception('Yaml not installed. composer require symfony/yaml');
23
        }
24
25
        $contents = file_get_contents($path);
26
        $data = Yaml::parse($contents);
27
        parent::__construct($data);
28
    }
29
}
30