VeloStations   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 13
dl 0
loc 35
ccs 16
cts 16
cp 1
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A allWithStatus() 0 12 1
A all() 0 7 1
A statuses() 0 3 1
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