WindowsPathBuilder   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 2
lcom 1
cbo 2
dl 0
loc 36
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getPermutations() 0 6 1
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