Skip to content

Commit 955d034

Browse files
committed
Added ability to sort results
1 parent d21fc3f commit 955d034

File tree

2 files changed

+69
-39
lines changed

2 files changed

+69
-39
lines changed

.travis.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
language: php
2+
3+
php:
4+
- 7.1
5+
- 7.2
6+
- 7.3
7+
- 7.4
8+
9+
env:
10+
matrix:
11+
- COMPOSER_FLAGS="--prefer-lowest"
12+
- COMPOSER_FLAGS=""
13+
14+
before_script:
15+
- travis_retry composer self-update
16+
- travis_retry composer update ${COMPOSER_FLAGS} --no-interaction --prefer-source
17+
18+
script:
19+
- vendor/bin/phpunit --coverage-text --coverage-clover=coverage.clover
20+
21+
after_script:
22+
- php vendor/bin/ocular code-coverage:upload --format=php-clover coverage.clover

src/LaravelVehapi.php

Lines changed: 47 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -39,121 +39,129 @@ public function getAllYears($sort = 'asc')
3939
/**
4040
* Return the range of years as supplied.
4141
*
42-
* @param $minYear
43-
* @param $maxYear
42+
* @param int $minYear
43+
* @param int $maxYear
4444
* @param string $sort
4545
* @return mixed
4646
*/
47-
public function getYearsRange($minYear, $maxYear, $sort = 'asc')
47+
public function getYearsRange(int $minYear, int $maxYear, $sort = 'asc')
4848
{
4949
return json_decode(Http::withToken($this->vehApiToken)->get('https://vehapi.com/api/'.$this->vehApiVersion.'/car-lists/get/range/years/'.$minYear.'/'.$maxYear.'/'.$sort), true);
5050
}
5151

5252
/**
5353
* Return all makes available.
5454
*
55+
* @param string $sort
5556
* @return mixed
5657
*/
57-
public function getAllMakes()
58+
public function getAllMakes($sort = 'asc')
5859
{
59-
return json_decode(Http::withToken($this->vehApiToken)->get('https://vehapi.com/api/'.$this->vehApiVersion.'/car-lists/get/all/car/makes'), true);
60+
return json_decode(Http::withToken($this->vehApiToken)->get('https://vehapi.com/api/'.$this->vehApiVersion.'/car-lists/get/all/car/makes/'.$sort), true);
6061
}
6162

6263
/**
6364
* Return the makes available for the year supplied.
6465
*
65-
* @param $year
66+
* @param int $year
67+
* @param string $sort
6668
* @return mixed
6769
*/
68-
public function getMakesByYear($year)
70+
public function getMakesByYear(int $year, $sort = 'asc')
6971
{
70-
return json_decode(Http::withToken($this->vehApiToken)->get('https://vehapi.com/api/'.$this->vehApiVersion.'/car-lists/get/car/makes/'.$year), true);
72+
return json_decode(Http::withToken($this->vehApiToken)->get('https://vehapi.com/api/'.$this->vehApiVersion.'/car-lists/get/car/makes/'.$year.'/'.$sort), true);
7173
}
7274

7375
/**
7476
* Return the range of years as supplied.
7577
*
76-
* @param $minYear
77-
* @param $maxYear
78+
* @param int $minYear
79+
* @param int $maxYear
80+
* @param string $sort
7881
* @return mixed
7982
*/
80-
public function getMakesByYearsRange($minYear, $maxYear)
83+
public function getMakesByYearsRange(int $minYear, int $maxYear, $sort = 'asc')
8184
{
82-
return json_decode(Http::withToken($this->vehApiToken)->get('https://vehapi.com/api/'.$this->vehApiVersion.'/car-lists/get/car/makes/in-range/'.$minYear.'/'.$maxYear), true);
85+
return json_decode(Http::withToken($this->vehApiToken)->get('https://vehapi.com/api/'.$this->vehApiVersion.'/car-lists/get/car/makes/in-range/'.$minYear.'/'.$maxYear.'/'.$sort), true);
8386
}
8487

8588
/**
8689
* Return the models available for the make supplied.
8790
*
88-
* @param $make
91+
* @param string $make
92+
* @param string $sort
8993
* @return mixed
9094
*/
91-
public function getAllModelsByMake($make)
95+
public function getAllModelsByMake(string $make, $sort = 'asc')
9296
{
93-
return json_decode(Http::withToken($this->vehApiToken)->get('https://vehapi.com/api/'.$this->vehApiVersion.'/car-lists/get/all/car/models/'.$make), true);
97+
return json_decode(Http::withToken($this->vehApiToken)->get('https://vehapi.com/api/'.$this->vehApiVersion.'/car-lists/get/all/car/models/'.$make.'/'.$sort), true);
9498
}
9599

96100
/**
97101
* Return the models available for the year & make supplied.
98102
*
99-
* @param $year
100-
* @param $make
103+
* @param int $year
104+
* @param string $make
105+
* @param string $sort
101106
* @return mixed
102107
*/
103-
public function getModelsByYearAndMake($year, $make)
108+
public function getModelsByYearAndMake(int $year, string $make, $sort = 'asc')
104109
{
105-
return json_decode(Http::withToken($this->vehApiToken)->get('https://vehapi.com/api/'.$this->vehApiVersion.'/car-lists/get/car/models/'.$year.'/'.$make), true);
110+
return json_decode(Http::withToken($this->vehApiToken)->get('https://vehapi.com/api/'.$this->vehApiVersion.'/car-lists/get/car/models/'.$year.'/'.$make.'/'.$sort), true);
106111
}
107112

108113
/**
109114
* Return the trims available for the year, make & model supplied.
110115
*
111-
* @param $year
112-
* @param $make
113-
* @param $model
116+
* @param int $year
117+
* @param string $make
118+
* @param string $model
119+
* @param string $sort
114120
* @return mixed
115121
*/
116-
public function getTrimsByYearMakeAndModel($year, $make, $model)
122+
public function getTrimsByYearMakeAndModel(int $year, string $make, string $model, $sort = 'asc')
117123
{
118-
return json_decode(Http::withToken($this->vehApiToken)->get('https://vehapi.com/api/'.$this->vehApiVersion.'/car-lists/get/car/trims/'.$year.'/'.$make.'/'.$model), true);
124+
return json_decode(Http::withToken($this->vehApiToken)->get('https://vehapi.com/api/'.$this->vehApiVersion.'/car-lists/get/car/trims/'.$year.'/'.$make.'/'.$model.'/'.$sort), true);
119125
}
120126

121127
/**
122128
* Return the transmissions available for the year, make,model & trim supplied.
123129
*
124-
* @param $year
125-
* @param $make
126-
* @param $model
127-
* @param $trim
130+
* @param int $year
131+
* @param string $make
132+
* @param string $model
133+
* @param string $trim
134+
* @param string $sort
128135
* @return mixed
129136
*/
130-
public function getTransmissionsByYearMakeModelAndTrim($year, $make, $model, $trim)
137+
public function getTransmissionsByYearMakeModelAndTrim(int $year, string $make, string $model, string $trim, $sort = 'asc')
131138
{
132-
return json_decode(Http::withToken($this->vehApiToken)->get('https://vehapi.com/api/'.$this->vehApiVersion.'/car-lists/get/car/transmissions/'.$year.'/'.$make.'/'.$model.'/'.$trim), true);
139+
return json_decode(Http::withToken($this->vehApiToken)->get('https://vehapi.com/api/'.$this->vehApiVersion.'/car-lists/get/car/transmissions/'.$year.'/'.$make.'/'.$model.'/'.$trim.'/'.$sort), true);
133140
}
134141

135142
/**
136143
* Return engines available for the year, make, model & transmission supplied.
137144
*
138-
* @param $year
139-
* @param $make
140-
* @param $model
141-
* @param $trim
142-
* @param $transmission
145+
* @param int $year
146+
* @param string $make
147+
* @param string $model
148+
* @param string $trim
149+
* @param string $transmission
150+
* @param string $sort
143151
* @return mixed
144152
*/
145-
public function getEnginesByYearMakeModelTrimAndTransmission($year, $make, $model, $trim, $transmission)
153+
public function getEnginesByYearMakeModelTrimAndTransmission(int $year, string $make, string $model, string $trim, string $transmission, $sort = 'asc')
146154
{
147-
return json_decode(Http::withToken($this->vehApiToken)->get('https://vehapi.com/api/'.$this->vehApiVersion.'/car-lists/get/car/engines/'.$year.'/'.$make.'/'.$model.'/'.$trim.'/'.$transmission), true);
155+
return json_decode(Http::withToken($this->vehApiToken)->get('https://vehapi.com/api/'.$this->vehApiVersion.'/car-lists/get/car/engines/'.$year.'/'.$make.'/'.$model.'/'.$trim.'/'.$transmission.'/'.$sort), true);
148156
}
149157

150158
/**
151159
* Return the logo for the make supplied.
152160
*
153-
* @param $make
161+
* @param string $make
154162
* @return mixed
155163
*/
156-
public function getMakeLogo($make)
164+
public function getMakeLogo(string $make)
157165
{
158166
return json_decode(Http::withToken($this->vehApiToken)->get('https://vehapi.com/api/'.$this->vehApiVersion.'/car-logos/img/'.$make), true);
159167
}

0 commit comments

Comments
 (0)