Passed
Push — main ( 03d0aa...06b87c )
by Stanislav
02:17
created

ArgumentResolver::resolve()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 12
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 6
nc 2
nop 1
dl 0
loc 12
ccs 7
cts 7
cp 1
crap 2
rs 10
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace Diezz\YamlToObjectMapper\Resolver;
4
5
abstract class ArgumentResolver
6
{
7
    protected bool $isResolved = false;
8
    protected mixed $resolvedValue = null;
9
    protected ?ArgumentResolver $after = null;
10
11 8
    public function resolve($context = null): mixed
12
    {
13 8
        if ($this->isResolved) {
14 6
            return $this->resolvedValue;
15
        }
16
17 8
        $result = $this->doResolve($context);
18
19 8
        $this->resolvedValue = $result;
20 8
        $this->isResolved = true;
21
22 8
        return $result;
23
    }
24
25
    abstract protected function doResolve($context = null);
26
}
27