ApiDataProcessing::loopThroughTemp()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 5
c 1
b 0
f 0
nc 2
nop 3
dl 0
loc 8
ccs 6
cts 6
cp 1
crap 2
rs 10
1
<?php
2
3
namespace Asti\Weather;
4
5
6
/**
7
 * A sample controller to show how a controller class can be implemented.
8
 * The controller will be injected with $di if implementing the interface
9
 * ContainerInjectableInterface, like this sample class does.
10
 * The controller is mounted on a particular route and can then handle all
11
 * requests for that mount point.
12
 *
13
 * @SuppressWarnings(PHPMD.TooManyPublicMethods)
14
 */
15
class ApiDataProcessing
16
{
17
18 3
    public function loopThroughDate($dateArray): array
19
    {
20 3
        $newDateArray = [];
21 3
        forEach ($dateArray as $date) {
22 3
            $modifiedDate = date("Y-m-d", array_shift($date));
23 3
            array_push($newDateArray, $modifiedDate);
24
        }
25 3
        return $newDateArray;
26
    }
27 3
    public function loopThroughTemp($dateArray, $el1, $el2): array
28
    {
29 3
        $newTempArray = [];
30 3
        forEach ($dateArray as $temp) {
31 3
            $modTemp = $temp[$el1][$el2];
32 3
            array_push($newTempArray, substr($modTemp,0 ,5));
33
        }
34 3
        return $newTempArray;
35
    }
36 3
    public function loopThroughDesc($dateArray, $el1, $el2): array
37
    {
38 3
        $newDescArray = [];
39 3
        forEach ($dateArray as $desc) {
40 3
            $modDesc = $desc[$el1][0][$el2];
41 3
            array_push($newDescArray, $modDesc);
42
        }
43 3
        return $newDescArray;
44
    }
45
}
46