IbanField   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 4

Importance

Changes 5
Bugs 1 Features 0
Metric Value
wmc 3
c 5
b 1
f 0
lcom 0
cbo 4
dl 0
loc 22
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 3
1
<?php
2
3
namespace fieldwork\components;
4
5
use fieldwork\sanitizers;
6
use fieldwork\validators;
7
8
class IbanField extends TextField
9
{
10
11
    /**
12
     * Creates a new text field and adds IBAN sanitizer and validator
13
     *
14
     * @param string     $slug
15
     * @param string     $label
16
     * @param string     $value
17
     * @param int|string $errorMsg         The error message to show if the field value is not valid
18
     * @param bool       $convertBban      Whether to permit input of bban number (will be converted using openiban API)
19
     * @param string     $openIbanUsername openiban API username
20
     * @param string     $openIbanPassword openiban API password
21
     */
22
    public function __construct ($slug, $label, $value = '', $errorMsg = validators\IbanFieldValidator::ERROR, $convertBban = false, $openIbanUsername = null, $openIbanPassword = null)
23
    {
24
        parent::__construct($slug, $label, $value, 0);
25
        $this->addSanitizer(new sanitizers\FieldUppercaser());
26
        $this->addSanitizer(new sanitizers\IbanSanitizer($convertBban ? $openIbanUsername : null, $convertBban ? $openIbanPassword : null));
27
        $this->addValidator(new validators\IbanFieldValidator($convertBban, $errorMsg));
28
    }
29
}