Completed
Push — master ( 124fed...6caa0a )
by Tomáš
12s
created

SiteConfigurationFactory::create()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 12
ccs 6
cts 6
cp 1
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 6
nc 2
nop 0
crap 2
1
<?php
2
3
/*
4
 * This file is a part of Sculpin.
5
 *
6
 * (c) Dragonfly Development Inc.
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Symplify\PHP7_Sculpin\Configuration;
13
14
use Dflydev\DotAccessConfiguration\Configuration;
15
use Dflydev\DotAccessConfiguration\ConfigurationInterface;
16
use Symfony\Component\Yaml\Yaml;
17
18
final class SiteConfigurationFactory
19
{
20
    /**
21
     * @var string
22
     */
23
    private $rootDir;
24
25 2
    public function __construct(string $rootDir)
26
    {
27 2
        $this->rootDir = $rootDir;
28 2
    }
29
30 2
    public function create() : ConfigurationInterface
31
    {
32 2
        $configuration = new Configuration();
33
34 2
        if (file_exists($file = $this->rootDir.'/config/sculpin_site.yml')) {
35 1
            $configuration->importRaw(
36 1
                Yaml::parse(file_get_contents($file))
37
            );
38
        }
39
40 2
        return $configuration;
41
    }
42
}
43