Code Duplication    Length = 15-15 lines in 2 locations

src/Loader/JsonLoader.php 1 location

@@ 9-23 (lines=15) @@
6
7
use Webmozart\Assert\Assert;
8
9
class JsonLoader extends ArrayLoader implements Loader
10
{
11
    public function __construct(string $content)
12
    {
13
        if (is_file($content) && is_readable($content)) {
14
            $content = file_get_contents($content);
15
        }
16
17
        $content = json_decode($content, true);
18
19
        Assert::isArray($content, 'config could not be parsed');
20
21
        parent::__construct($content);
22
    }
23
}
24

src/Loader/YamlLoader.php 1 location

@@ 10-24 (lines=15) @@
7
use Symfony\Component\Yaml\Yaml;
8
use Webmozart\Assert\Assert;
9
10
class YamlLoader extends ArrayLoader implements Loader
11
{
12
    public function __construct(string $content)
13
    {
14
        if (is_file($content) && is_readable($content)) {
15
            $content = file_get_contents($content);
16
        }
17
18
        $content = Yaml::parse($content);
19
20
        Assert::isArray($content, 'config could not be parsed');
21
22
        parent::__construct($content);
23
    }
24
}
25