WindowsPathBuilder::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 2
1
<?php
2
namespace Nubs\Which\PathBuilder;
3
4
/**
5
 * A path builder for building paths to commands on Windows.
6
 */
7
class WindowsPathBuilder implements PathBuilderInterface
8
{
9
    use WindowsFileAppenderTrait;
10
    use WindowsExtensionAppenderTrait;
11
12
    /** @type array The base paths for files. */
13
    private $_paths;
14
15
    /** @type array The supported extensions for files. */
16
    private $_extensions;
17
18
    /**
19
     * Initialize the path builder.
20
     *
21
     * @param array $paths The base paths for files.
22
     * @param array $extensions The supported extensions for files.
23
     */ 
24
    public function __construct(array $paths, array $extensions)
25
    {
26
        $this->_paths = array_values(array_unique($paths));
27
        $this->_extensions = array_values(array_unique($extensions));
28
    }
29
30
    /**
31
     * Gets the permutations of paths to the given file.
32
     *
33
     * @param string $file The file to build paths to.
34
     * @return array The permutations of file paths.
35
     */
36
    public function getPermutations($file)
37
    {
38
        $paths = $this->_appendFileToPaths($this->_paths, $file);
39
40
        return $this->_appendExtensionsToPaths($paths, $this->_extensions);
41
    }
42
}
43