Passed
Pull Request — master (#20158)
by Robert
09:09
created

CallbackDependency   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
dl 0
loc 17
ccs 2
cts 2
cp 1
rs 10
c 1
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A generateDependencyData() 0 3 1
1
<?php
2
3
/**
4
 * @link https://www.yiiframework.com/
5
 * @copyright Copyright (c) 2008 Yii Software LLC
6
 * @license https://www.yiiframework.com/license/
7
 */
8
9
namespace yii\caching;
10
11
/**
12
 * CallbackDependency represents a dependency based on the result of a callback function.
13
 *
14
 * Callback function should return a value that serves as the dependency data.
15
 *
16
 * For more details and usage information on Cache, see the [guide article on caching](guide:caching-overview).
17
 *
18
 * @author Vlad Varlamov <[email protected]>
19
 * @since 2.0.50
20
 */
21
class CallbackDependency extends Dependency
22
{
23
    /**
24
     * @var callable the PHP callback that will be called to determine if the dependency has been changed.
25
     */
26
    public $callback;
27
28
29
    /**
30
     * Generates the data needed to determine if dependency has been changed.
31
     * This method returns the result of the callback function.
32
     * @param CacheInterface $cache the cache component that is currently evaluating this dependency
33
     * @return mixed the data needed to determine if dependency has been changed.
34
     */
35 2
    protected function generateDependencyData($cache)
36
    {
37 2
        return ($this->callback)();
38
    }
39
}
40