Conditions | 1 |
Paths | 1 |
Total Lines | 12 |
Code Lines | 6 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
22 | public function random() |
||
23 | { |
||
24 | /** @var \yii\caching\Cache $cache */ |
||
25 | $cache = Instance::ensure($this->cache); |
||
26 | |||
27 | $items = $cache->getOrSet(__METHOD__, function() { |
||
28 | return (new \jakim\ua\UserAgent())->fetch(); |
||
29 | }, 60 * 60 * 24 * 30); |
||
30 | |||
31 | shuffle($items); |
||
|
|||
32 | |||
33 | return $items['0']; |
||
34 | } |
||
35 | } |