Crc32Hasher   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 5
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 2
c 0
b 0
f 0
dl 0
loc 5
rs 10
ccs 2
cts 2
cp 1
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A hash() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
/**
6
 * This file is part of Esi\ConsistentHash.
7
 *
8
 * (c) Eric Sizemore <[email protected]>
9
 * (c) Paul Annesley <[email protected]>
10
 *
11
 * This source file is subject to the MIT license. For the full copyright and
12
 * license information, please view the LICENSE file that was distributed with
13
 * this source code.
14
 */
15
16
namespace Esi\ConsistentHash\Hasher;
17
18
/**
19
 * Uses CRC32 to hash a value into a signed 32bit int address space.
20
 * Under 32bit PHP this (safely) overflows into negatives ints.
21
 */
22
class Crc32Hasher implements HasherInterface
23
{
24 2
    public function hash(string $string): int
25
    {
26 2
        return crc32($string);
27
    }
28
}
29