Completed
Push — master ( 9bf55b...1ce859 )
by Jefersson
25s
created

FeatureResolve   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 58.33%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 6
c 1
b 0
f 1
lcom 1
cbo 1
dl 0
loc 33
ccs 7
cts 12
cp 0.5833
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __invoke() 0 7 1
A __construct() 0 4 1
A getDirectory() 0 4 2
A getFeatureMatch() 0 4 2
1
<?php
2
3
namespace KawaiiGherkin;
4
5
use Symfony\Component\Finder\Finder;
6
7
final class FeatureResolve
8
{
9
    /**
10
     * @var string
11
     */
12
    private $directoryOrFile;
13
14
    /**
15
     * @param string $directoryOrFile
16
     */
17 5
    public function __construct($directoryOrFile)
18
    {
19 5
        $this->directoryOrFile = $directoryOrFile;
20 5
    }
21
22 5
    private function getDirectory()
23
    {
24 5
        return is_dir($this->directoryOrFile) ? $this->directoryOrFile : dirname($this->directoryOrFile);
25
    }
26
27 5
    private function getFeatureMatch()
28
    {
29 5
        return is_dir($this->directoryOrFile) ? '*.feature' : basename($this->directoryOrFile);
30
    }
31
32
    public function __invoke()
33
    {
34
        return Finder::create()
35
            ->files()
36
            ->in($this->getDirectory())
37
            ->name($this->getFeatureMatch());
38
    }
39
}
40