EnvironmentFinder::getFromFiles()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

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