Passed
Push — main ( 4a5561...6b28c5 )
by Osvaldo
01:44
created

RangoDeEdad::setRangoDeEdad()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 14
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 4
eloc 5
c 2
b 0
f 0
nc 3
nop 1
dl 0
loc 14
rs 10
1
<?php
2
namespace src;
3
4
use src\Edad;
5
6
class RangoDeEdad
7
{
8
    private string $_rangoDeEdad;
9
    private $_rangos = array(
10
        '15' => 19,
11
        '20' => 24,
12
        '25' => 29,
13
        '30' => 34,
14
        '35' => 39,
15
        '40' => 44,
16
        '45' => 49,
17
        '50' => 54,
18
        '55' => 59,
19
        '60' => 64,
20
        '65' => 69,
21
        '70' => 99  
22
    );
23
24
    public function __construct(Edad $Edad)
25
    {
26
        $this->_rangoDeEdad = $this->setRangoDeEdad($Edad->edad());
27
    }
28
29
    public function rangoDeEdad(): string
30
    {
31
        return $this->_rangoDeEdad;
32
    }
33
34
    private function setRangoDeEdad(int $edad): string
35
    {
36
        $rango = '';
37
38
        foreach($this->_rangos as $k => $r)
39
        {
40
            
41
            if($edad >= $k && $edad <= $r)
42
            {
43
                $rango = "$k-$r";
44
            }
45
        }
46
47
        return $rango;  
48
    }
49
}