Completed
Push — master ( f81cf6...7fbbb0 )
by Oleg
03:40
created

CachedProvider::provide()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 3
nc 2
nop 0
dl 0
loc 7
rs 10
c 0
b 0
f 0
ccs 4
cts 4
cp 1
crap 2
1
<?php
2
declare(strict_types=1);
3
4
namespace SlayerBirden\DFCodeGeneration\Generator\DataProvider;
5
6
final class CachedProvider implements DataProviderInterface
7
{
8
    /**
9
     * @var
10
     */
11
    private $cachedData;
12
    /**
13
     * @var DataProviderInterface
14
     */
15
    private $provider;
16
17 2
    public function __construct(DataProviderInterface $provider)
18
    {
19 2
        $this->provider = $provider;
20 2
    }
21
22 2
    public function provide(): array
23
    {
24 2
        if ($this->cachedData === null) {
25 2
            $this->cachedData = $this->provider->provide();
26
        }
27
28 2
        return $this->cachedData;
29
    }
30
}
31