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

InverseCalculator::getBelfioreCode()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 1
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 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 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