ValidatesSamplingSize::validateSamplingSize()   A
last analyzed

Complexity

Conditions 4
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 4
nc 3
nop 1
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