Completed
Branch master (082d55)
by Rudie
02:26
created

Vehicle   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
c 1
b 0
f 0
lcom 0
cbo 2
dl 0
loc 34
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 19 3
1
<?php
2
3
namespace rdx\fuelly;
4
5
use rdx\fuelly\Client;
6
use rdx\fuelly\FuelUp;
7
8
class Vehicle {
9
10
	public $client; // rdx\fuelly\Client
11
12
	public $id = 0;
13
	public $url = '';
14
	public $name = '';
15
	public $image = '';
16
	public $trend = array();
17
18
	/**
19
	 *
20
	 */
21
	public function __construct( Client $client, array $vehicle ) {
22
		$this->client = $client;
23
24
		$this->id = $vehicle['id'];
25
		$this->url = $vehicle['url'];
26
		$this->name = $vehicle['name'];
27
		$this->image = $vehicle['image'];
28
29
		if ( isset($vehicle['trend']) ) {
30
			$input = $client->createTrendInputConversion();
31
32
			foreach ( $vehicle['trend'] as $fuelup) {
33
				$this->trend[] = FuelUp::createFromTrend($this, $fuelup, $input);
34
			}
35
36
			// Sort by date DESC
37
			usort($this->trend, array(FuelUp::class, 'dateCmp'));
38
		}
39
	}
40
41
}
42