Completed
Pull Request — master (#12)
by Antonio
01:27
created

InverseCalculator   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 2
dl 0
loc 44
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 2
A getBelfioreCode() 0 3 1
A getSubject() 0 7 1
1
<?php
2
3
namespace CodiceFiscale;
4
5
/**
6
 * Description of InverseCalculator
7
 *
8
 * @author Antonio Turdo <[email protected]>
9
 */
10
class InverseCalculator extends Validator {
11
    
12
    private $belfioreCode = null;
13
    
14
    /**
15
     * Create an InverseCalculator instance.
16
     * 
17
     * @param string $codiceFiscale the codice fiscale to validate
18
     * @param array $properties  An array with additional properties.
19
     */
20
    public function __construct($codiceFiscale, $properties = array()) {
21
        parent::__construct($codiceFiscale, $properties);
22
        
23
        if ($this->isFormallyValid()) {
24
            $codiceFiscaleWithoutOmocodia = $this->getCodiceFiscaleWithoutOmocodia();
25
            
26
            // calculate belfiore code
27
            $this->belfioreCode = substr($codiceFiscaleWithoutOmocodia, 11, 4);
28
        }
29
    }
30
31
    /**
32
     * Return the belfiore code
33
     * 
34
     * @return string
35
     */
36
    public function getBelfioreCode() {
37
        return $this->belfioreCode;
38
    }
39
40
    /**
41
     * Return the Subject calculated from codice fiscale 
42
     * 
43
     * @return \CodiceFiscale\Subject
44
     */
45
    public function getSubject(){
46
        return new Subject(array(
47
            "gender" => $this->getGender(),
48
            "birthDate" => $this->getBirthDate(),
49
            "belfioreCode" => $this->getBelfioreCode()
50
                ));
51
    }   
52
    
53
}
54