Completed
Push — master ( 2e21dc...b663e1 )
by Bill
04:37 queued 02:23
created

EnvironmentFinder::getFromFile()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 6
nc 2
nop 1
1
<?php
2
3
namespace Bmitch\Envsync\Finders;
4
5
class EnvironmentFinder
6
{
7
    /**
8
     * Gets the environment variables defined within $file.
9
     * @param  string $file Path and filename.
10
     * @return array
11
     */
12
    public function getFromFile($file)
13
    {
14
        if (preg_match("/.*.php/", $file)) {
15
            return PhpFileFinder::find($file);
16
        } else {
17
            return EnvFileFinder::find($file);
18
        }
19
20
        return [];
0 ignored issues
show
Unused Code introduced by
return array(); does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
21
    }
22
23
    /**
24
     * Gets the environment variables defined within the $files.
25
     * @param  array $files Array of paths and filenames.
26
     * @return array
27
     */
28
    public function getFromFiles(array $files)
29
    {
30
        $envs = [];
31
32
        foreach ($files as $file) {
33
            $envs = array_merge($envs, $this->getFromFile($file));
34
        }
35
36
        return $envs;
37
    }
38
}
39