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

AssertionsTrait   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 17
ccs 5
cts 5
cp 1
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
     * 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