CappedStorageHits::__construct()   A
last analyzed

Complexity

Conditions 4
Paths 2

Size

Total Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 4
dl 0
loc 12
rs 9.8666
c 0
b 0
f 0
nc 2
nop 1
1
<?php
2
namespace PHPDaemon\Cache;
3
4
/**
5
 * CappedStorageHits
6
 * @package PHPDaemon\Cache
7
 * @author  Vasily Zorin <[email protected]>
8
 */
9
class CappedStorageHits extends CappedStorage
10
{
11
12
    /**
13
     * Constructor
14
     * @param  integer $max Maximum number of cached elements
0 ignored issues
show
Documentation introduced by
Should the type for parameter $max not be integer|null?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
15
     */
16
    public function __construct($max = null)
17
    {
18
        if ($max !== null) {
19
            $this->maxCacheSize = $max;
20
        }
21
        $this->sorter = function ($a, $b) {
22
            if ($a->hits === $b->hits) {
23
                return 0;
24
            }
25
            return ($a->hits < $b->hits) ? 1 : -1;
26
        };
27
    }
28
}
29