GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

BloomFilter::contains()   A
last analyzed

Complexity

Conditions 3
Paths 3

Size

Total Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 10
rs 9.9332
c 0
b 0
f 0
cc 3
nc 3
nop 1
1
<?php
2
3
namespace maxwilms\BloomFilter;
4
5
use maxwilms\BloomFilter\Hash\MultiHash;
6
7
class BloomFilter
8
{
9
10
    protected $bitField;
11
12
    protected $multiHash;
13
14
    public function __construct(BitField $bitField, MultiHash $multiHash)
15
    {
16
        $this->bitField = $bitField;
17
        $this->multiHash = $multiHash;
18
    }
19
20
    /**
21
     * @param string $item add item to set
22
     */
23
    public function add($item)
24
    {
25
        foreach ($this->multiHash->hash($item) as $bit) {
26
            $this->bitField->set($bit);
27
        }
28
    }
29
30
    /**
31
     * @param string $item
32
     * @return bool "possibly in set" or "definitely not in set"
33
     */
34
    public function contains($item)
35
    {
36
        foreach ($this->multiHash->hash($item) as $bit) {
37
            if (!$this->bitField->has($bit)) {
38
                return false;
39
            }
40
        }
41
42
        return true;
43
    }
44
45
}
46