YamlConfigLoader::supports()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 2
dl 0
loc 5
rs 10
c 0
b 0
f 0
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
}