CachingExecutableFinder::getExecutablePath()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 0
1
<?php
2
3
namespace RMiller\BehatSpec\Extension\PhpSpecRunExtension\Process;
4
5
use Symfony\Component\Process\PhpExecutableFinder;
6
7
class CachingExecutableFinder
8
{
9
    /**
10
     * @var PhpExecutableFinder
11
     */
12
    private $executableFinder;
13
14
    /**
15
     * @var null|false|string
16
     */
17
    private $executablePath;
18
19
    /**
20
     * @param PhpExecutableFinder $executableFinder
21
     */
22
    public function __construct(PhpExecutableFinder $executableFinder)
23
    {
24
        $this->executableFinder = $executableFinder;
25
    }
26
27
    /**
28
     * @return false|string
29
     */
30
    public function getExecutablePath()
31
    {
32
        if (null === $this->executablePath) {
33
            $this->executablePath = $this->executableFinder->find();
34
        }
35
36
        return $this->executablePath;
37
    }
38
}
39