Completed
Push — master ( c29bcc...91a13a )
by Hannes
22s
created

AssertionsTrait::assertNumber()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

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