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

RangoDeEdad   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 42
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 22
c 2
b 0
f 0
dl 0
loc 42
rs 10
wmc 6

3 Methods

Rating   Name   Duplication   Size   Complexity  
A rangoDeEdad() 0 3 1
A __construct() 0 3 1
A setRangoDeEdad() 0 14 4
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
}