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

CallbackDependency::generateDependencyData()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 2
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 4
rs 10
1
<?php
2
namespace Yiisoft\CacheOld\DependencyOld;
3
4
use Yiisoft\CacheOld\CacheInterface;
5
6
/**
7
 * CallbackDependency represents a dependency based on the result of a callback.
8
 *
9
 * The dependency is reported as unchanged if and only if the result of the callback is
10
 * the same as the one evaluated when storing the data to cache.
11
 */
12
class CallbackDependency extends Dependency
13
{
14
    private $callback;
15
16
    public function __construct(callable $callback)
17
    {
18
        $this->callback = $callback;
19
    }
20
21
    protected function generateDependencyData(CacheInterface $cache)
22
    {
23
        $callback = $this->callback;
24
        return $callback();
25
    }
26
}
27