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.

BloomFilterGenerator   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 1
lcom 0
cbo 3
dl 0
loc 25
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A generate() 0 15 1
1
<?php
2
3
namespace maxwilms\BloomFilter;
4
5
use maxwilms\BloomFilter\Hash\MultiHash;
6
7
class BloomFilterGenerator
8
{
9
10
    /**
11
     * @param $expectedValues
12
     * @param float $falsePositiveProbability
13
     * @return BloomFilter
14
     */
15
    public static function generate($expectedValues, $falsePositiveProbability = 0.1)
16
    {
17
        $sizeOfBitField = (int) ceil(($expectedValues * log($falsePositiveProbability)) / log(1 / (pow(2, log(2)))));
18
        $hashFunctions = (int) ($sizeOfBitField / $expectedValues * log(2));
19
20
        $multiHash = new MultiHash();
21
22
        $multiHash->setUpperBound($sizeOfBitField);
23
        $multiHash->setHashCount($hashFunctions);
24
25
        return new BloomFilter(
26
            new IntBitField($sizeOfBitField),
27
            $multiHash
28
        );
29
    }
30
31
}
32