Completed
Pull Request — master (#5)
by
unknown
08:52
created

Base::validateNumber()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

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