Passed
Pull Request — master (#30)
by Alexander
02:06
created

AnyDependency::evaluateDependency()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 2
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 4
rs 10
1
<?php
2
3
namespace Yiisoft\CacheOld\DependencyOld;
4
5
use Yiisoft\CacheOld\CacheInterface;
6
7
/**
8
 * AnyDependency represents a dependency based on the result of a callback.
9
 *
10
 * The dependency is reported as changed if any sub-dependency is changed.
11
 */
12
class AnyDependency extends Dependency
13
{
14
    /**
15
     * @var Dependency[]
16
     */
17
    private $dependencies;
18
19
    /**
20
     * @param Dependency[] $dependencies list of dependencies that this dependency is composed of.
21
     * Each array element must be a dependency object.
22
     */
23
    public function __construct(array $dependencies = [])
24
    {
25
        $this->dependencies = $dependencies;
26
    }
27
28
    public function evaluateDependency(CacheInterface $cache): void
29
    {
30
        foreach ($this->dependencies as $dependency) {
31
            $dependency->evaluateDependency($cache);
32
        }
33
    }
34
35
    protected function generateDependencyData(CacheInterface $cache)
36
    {
37
        return null;
38
    }
39
40
    public function isChanged(CacheInterface $cache): bool
41
    {
42
        foreach ($this->dependencies as $dependency) {
43
            if ($dependency->isChanged($cache)) {
44
                return true;
45
            }
46
        }
47
48
        return false;
49
    }
50
}
51