Completed
Push — master ( 91a13a...c756b3 )
by Hannes
01:12
created

AssertionsTrait::assertNumber()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2.032

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 4
cts 5
cp 0.8
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 2.032
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace byrokrat\checkdigit;
6
7
trait AssertionsTrait
8
{
9
    /**
10
     * Assert that $number contains only numerical characters
11
     *
12
     * @throws InvalidStructureException If $number is not numerical
13
     */
14 27
    protected function assertNumber(string $number): void
15
    {
16 27
        if (!ctype_digit($number)) {
17 27
            throw new InvalidStructureException(
18 27
                "Number can only contain numerical characters, found <$number>"
19
            );
20
        }
21
    }
22
}
23