ConfigFinder::findConfigFile()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 7
nc 2
nop 1
dl 0
loc 11
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
/*
4
 * This file is part of the php-formatter package
5
 *
6
 * Copyright (c) 2014-2016 Marc Morera
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 *
11
 * Feel free to edit as you please, and have fun.
12
 *
13
 * @author Marc Morera <[email protected]>
14
 */
15
16
namespace Mmoreram\PHPFormatter\Finder;
17
18
use Symfony\Component\Yaml\Parser as YamlParser;
19
20
use Mmoreram\PHPFormatter\PHPFormatter;
21
22
/**
23
 * Class ConfigFinder.
24
 */
25
class ConfigFinder
26
{
27
    /**
28
     * Load, if exists, specific project configuration.
29
     *
30
     * @param string $path Path
31
     *
32
     * @return array loaded config
33
     */
34
    public function findConfigFile($path)
35
    {
36
        $configFilePath = rtrim($path, '/') . '/' . PHPFormatter::CONFIG_FILE_NAME;
37
        $config = [];
38
        if (is_file($configFilePath)) {
39
            $yamlParser = new YamlParser();
40
            $config = $yamlParser->parse(file_get_contents($configFilePath));
41
        }
42
43
        return $config;
44
    }
45
}
46