PosixPathBuilder::getPermutations()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

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