TomlFileLoader::loadFile()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 6
nc 3
nop 1
1
<?php
2
3
/**
4
 * This file is part of Bldr.io
5
 *
6
 * (c) Aaron Scherer <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE
10
 */
11
12
namespace Bldr\DependencyInjection\Loader;
13
14
use Symfony\Component\DependencyInjection\Exception\InvalidArgumentException;
15
use Yosymfony\Toml\Toml;
16
17
/**
18
 * @author Rob Loach <[email protected]>
19
 */
20
class TomlFileLoader extends JsonFileLoader
21
{
22
    use SupportsTrait;
23
24
    /**
25
     * Loads the Toml File
26
     *
27
     * @param string $file
28
     *
29
     * @throws \Symfony\Component\DependencyInjection\Exception\InvalidArgumentException
30
     * @return array
31
     */
32
    protected function loadFile($file)
33
    {
34
        if (!stream_is_local($file)) {
35
            throw new InvalidArgumentException(sprintf('This is not a local file "%s".', $file));
36
        }
37
38
        if (!file_exists($file)) {
39
            throw new InvalidArgumentException(sprintf('The service file "%s" is not valid.', $file));
40
        }
41
42
        return Toml::Parse($file);
43
    }
44
}
45