VeloStations::statuses()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Earnould\LaravelVeloApi;
4
5
class VeloStations
6
{
7
    protected $veloClient;
8
9 7
    public function __construct(VeloClientInterface $veloClient)
10
    {
11 7
        $this->veloClient = $veloClient;
12 7
    }
13
14 2
    public function all()
15
    {
16
        $stations = $this->veloClient->fetchStations()->map(function ($station) {
17 2
            return new Station($station);
18 2
        });
19
20 2
        return $stations;
21
    }
22
23 1
    public function allWithStatus()
24
    {
25 1
        $stations = $this->all();
26 1
        $statuses = $this->statuses();
27
28
        $stationsWithStatus = $stations->map(function ($station) use ($statuses) {
29 1
            $station->setStatus(collect($statuses)->firstWhere('id', $station->id));
30
31 1
            return $station;
32 1
        });
33
34 1
        return $stationsWithStatus;
35
    }
36
37 3
    public function statuses()
38
    {
39 3
        return $this->veloClient->fetchStationsStatuses();
40
    }
41
}
42