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

InverseCalculator   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 46
ccs 15
cts 15
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getSubject() 0 8 1
A getBelfioreCode() 0 4 1
A __construct() 0 11 2
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 15
    public function __construct($codiceFiscale, $properties = array())
21
    {
22 15
        parent::__construct($codiceFiscale, $properties);
23
        
24 15
        if ($this->isFormallyValid()) {
25 15
            $codiceFiscaleWithoutOmocodia = $this->getCodiceFiscaleWithoutOmocodia();
26
            
27
            // calculate belfiore code
28 15
            $this->belfioreCode = substr($codiceFiscaleWithoutOmocodia, 11, 4);
29 15
        }
30 15
    }
31
32
    /**
33
     * Return the belfiore code
34
     *
35
     * @return string
36
     */
37 15
    public function getBelfioreCode()
38
    {
39 15
        return $this->belfioreCode;
40
    }
41
42
    /**
43
     * Return the Subject calculated from codice fiscale
44
     *
45
     * @return \CodiceFiscale\Subject
46
     */
47 15
    public function getSubject()
48
    {
49 15
        return new Subject(array(
50 15
            "gender" => $this->getGender(),
51 15
            "birthDate" => $this->getBirthDate(),
52 15
            "belfioreCode" => $this->getBelfioreCode()
53 15
                ));
54
    }
55
}
56