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

CachedProvider   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 23
rs 10
c 0
b 0
f 0
ccs 7
cts 7
cp 1
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A provide() 0 7 2
A __construct() 0 3 1
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