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

AssertionsTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 16
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 80%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 16
ccs 4
cts 5
cp 0.8
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A assertNumber() 0 8 2
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