Passed
Push — master ( 12f961...e1bf1d )
by Evert
03:22
created

VeloStations::all()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

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