SepaCntryValidationCH::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 9
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
namespace SKien\Sepa\CntryValidation;
3
4
/**
5
 * Validation class for swiss IBAN and CI
6
 *
7
 * #### Valid testvalues
8
 * <table><tbody>
9
 * <tr><td>   IBAN   </td><td> CH18 0483 5029 8829 8100 0 </td></tr>
10
 * <tr><td>   BIC    </td><td> CRESCHZZ80A </td></tr>
11
 * <tr><td>   CI     </td><td> CH51 ZZZ 12345678901 </td></tr>
12
 * </tbody></table>
13
 *
14
 * #### IBAN format
15
 * #### ` CCpp bbbb bkkk kkkk kkkk k `
16
 * <table><tbody>
17
 * <tr><td>   CC     </td><td> ISO Country Code </td></tr>
18
 * <tr><td>   pp     </td><td> 2 digits IBAN checksum </td></tr>
19
 * <tr><td>   b      </td><td> banking code 5 digits </td></tr>
20
 * <tr><td>   k      </td><td> account number 12 digits </td></tr>
21
 * </tbody></table>
22
 *
23
 * Length: 21
24
 *
25
 * #### CI format
26
 * #### ` CCpp ZZZ nnnnnnnnnnnn `
27
 * <table><tbody>
28
 * <tr><td>   C      </td><td> ISO Country Code </td></tr>
29
 * <tr><td>   p      </td><td> 2 digits IBAN checksum </td></tr>
30
 * <tr><td>   Z      </td><td> 3 digits alphanum creditor business code </td></tr>
31
 * <tr><td>   n      </td><td> 11 digits numeric national identification code  </td></tr>
32
 * </tbody></table>
33
 *
34
 * Length: 18
35
 *
36
 * <b>All validation can be done with specification of length and regex to match format! </b>
37
 *
38
 * @package Sepa
39
 * @author Stefanius <[email protected]>
40
 * @copyright MIT License - see the LICENSE file for details
41
 */
42
class SepaCntryValidationCH extends SepaCntryValidationBase
43
{
44
    /**
45
     * Create instance of swiss validation.
46
     * @param string $strCntry  2 sign country code
47
     */
48
    public function __construct(string $strCntry)
49
    {
50
        $this->strCntry = 'CH';
51
        $this->iLenIBAN = 21;
52
        $this->strRegExIBAN = '/^([A-Z]){2}([0-9]){19}?$/';
53
        $this->iLenCI = 18;
54
        $this->strRegExCI = '/^([A-Z]){2}([0-9]){2}([0-9A-Z]){3}([0-9]){11}?$/';
55
56
        parent::__construct(strtoupper($strCntry));
57
    }
58
}