PhpBinValue::getValue()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 6
c 1
b 0
f 0
dl 0
loc 12
ccs 0
cts 10
cp 0
rs 10
cc 3
nc 3
nop 0
crap 12
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Setono\VariableResolver\Variable\Value;
6
7
use Symfony\Component\Process\PhpExecutableFinder;
8
9
final class PhpBinValue implements ValueInterface
10
{
11
    private ?string $value = null;
12
13
    public function getValue(): string
14
    {
15
        if (null === $this->value) {
16
            $phpBin = (new PhpExecutableFinder())->find();
17
            if (false === $phpBin) {
18
                throw new \RuntimeException('A PHP binary could not be found'); // todo better exception
19
            }
20
21
            $this->value = $phpBin;
22
        }
23
24
        return $this->value;
25
    }
26
}
27