Issues (76)

components/http/UserAgent.php (1 issue)

Labels
Severity
1
<?php
2
/**
3
 * Created for IG Monitoring.
4
 * User: jakim <[email protected]>
5
 * Date: 11.01.2018
6
 */
7
8
namespace app\components\http;
9
10
11
use yii\base\Component;
12
use yii\di\Instance;
13
14
class UserAgent extends Component
15
{
16
    public $cache = 'cache';
17
18
    /**
19
     * @return mixed
20
     * @throws \yii\base\InvalidConfigException
21
     */
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);
0 ignored issues
show
It seems like $items can also be of type false; however, parameter $array of shuffle() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

31
        shuffle(/** @scrutinizer ignore-type */ $items);
Loading history...
32
33
        return $items['0'];
34
    }
35
}