ValidatesSamplingSize   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 13
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 0
dl 0
loc 13
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A validateSamplingSize() 0 10 4
1
<?php
2
3
namespace Bdelespierre\PhpPhash\Command;
4
5
trait ValidatesSamplingSize
6
{
7
    public function validateSamplingSize(int $size)
8
    {
9
        if ($size < 8) {
10
            throw new \InvalidArgumentException('Sampling size must be greater or equal to 8');
11
        }
12
13
        if ($size ** 2 > PHP_INT_SIZE * 8 && !function_exists('gmp_init')) {
14
            throw new \InvalidArgumentException('Sampling size too large: reduce it or install PHP-GMP extension');
15
        }
16
    }
17
}
18