CachedProvider   A
last analyzed

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 20
    public function __construct(DataProviderInterface $provider)
18
    {
19 20
        $this->provider = $provider;
20 20
    }
21
22 20
    public function provide(): array
23
    {
24 20
        if ($this->cachedData === null) {
25 20
            $this->cachedData = $this->provider->provide();
26
        }
27
28 20
        return $this->cachedData;
29
    }
30
}
31