YamlConfigLoader   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 5
dl 0
loc 24
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A supports() 0 5 2
A load() 0 3 1
1
<?php
2
3
namespace Hyperized\Benchmark\Config;
4
5
use Symfony\Component\Config\Loader\FileLoader;
6
use Symfony\Component\Yaml\Yaml;
7
8
/**
9
 * Class YamlConfigLoader
10
 * @package Hyperized\Benchmark\Config
11
 */
12
class YamlConfigLoader extends FileLoader
13
{
14
    /**
15
     * @param mixed $resource   The resource
16
     * @param string|null $type The resource type or null if unknown
17
     *
18
     * @return mixed
19
     */
20
    public function load($resource, $type = null)
21
    {
22
        return Yaml::parse(\file_get_contents($resource));
23
    }
24
25
    /**
26
     * @param mixed $resource   A resource
27
     * @param string|null $type The resource type or null if unknown
28
     *
29
     * @return bool
30
     */
31
    public function supports($resource, $type = null): bool
32
    {
33
        return \is_string($resource) && 'yml' === \pathinfo(
34
                $resource,
35
                PATHINFO_EXTENSION
36
            );
37
    }
38
}