Utils::returnSubactividadAno()   A
last analyzed

Complexity

Conditions 4
Paths 3

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 20

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 10
ccs 0
cts 5
cp 0
rs 9.2
c 1
b 0
f 0
cc 4
eloc 5
nc 3
nop 3
crap 20
1
<?php
2
3
namespace Api\Helper;
4
5
final class Utils
6
{
7 2
    public static function returnSectorGas($arr, $sector, $gas)
8
    {
9 2
        foreach ($arr as $val) {
10 2
            if ($val['sector'] == $sector && $val['gas'] == $gas) {
11 2
                return $val['total'];
12
            }
13
        }
14 1
        return 0;
15
    }
16
17 4
    public static function returnSectorAno($arr, $sector, $year)
18
    {
19 4
        foreach ($arr as $val) {
20 4
            if ($val['sector'] == $sector && $val['year'] == $year) {
21 4
                return $val['total'];
22
            }
23
        }
24
        return 0;
25
    }
26
27
    public static function returnSubactividadAno($arr, $subactivity, $year)
28
    {
29
        foreach ($arr as $val) {
30
            if (trim($val['name']) == trim($subactivity) && $val['year'] == $year) {
31
                return $val['value'];
32
            }
33
        }
34
35
        return 0;
36
    }
37
38 1
    public static function returnCategoriaAno($arr, $category, $year)
39
    {
40 1
        foreach ($arr as $val) {
41 1
            if (trim($val['name']) == trim($category) && $val['year'] == $year) {
42 1
                return $val['value'];
43
            }
44
        }
45
        return 0;
46
    }
47
}
48