Completed
Push — master ( 929034...adc5e6 )
by Marcus
02:23
created

BigInt::minSignedValue()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Mbright\Validation\Rule\Validate\MySql;
4
5
/**
6
 * Validates that data can be inserted into one of the following column types:
7
 * - BIGINT
8
 */
9
class BigInt extends AbstractMySqlIntegerCase
10
{
11
    /**
12
     * {@inheritdoc}
13
     */
14 9
    protected function minSignedValue()
15
    {
16 9
        return -pow(2, 63);
17
    }
18
19
    /**
20
     * {@inheritdoc}
21
     */
22 9
    protected function maxSignedValue()
23
    {
24 9
        return pow(2, 63) - 1;
25
    }
26
27
    /**
28
     * {@inheritdoc}
29
     */
30 6
    protected function maxUnsignedValue()
31
    {
32 6
        return pow(2, 64) - 1;
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38 9
    protected function minUnSignedValue()
39
    {
40 9
        return 0;
41
    }
42
43
    /**
44
     * Ensures that the field's value is a valid Mysql standard int.
45
     *
46
     * @param object $subject
47
     * @param string $field
48
     *
49
     * @return bool
50
     */
51 27
    public function __invoke($subject, string $field): bool
52
    {
53 27
        $value = $subject->$field;
54
55 27
        return $this->isNumeric($value) && $this->isWithinBounds($value);
56
    }
57
}
58