Skip to content

Commit 93325f1

Browse files
joshuadegierStyleCIBot
authored andcommitted
Applied fixes from StyleCI
1 parent a2d039f commit 93325f1

File tree

2 files changed

+62
-45
lines changed

2 files changed

+62
-45
lines changed

src/Pro6pp.php

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
class Pro6pp
66
{
7-
87
private $api_format = '';
98

109
private $api_pretty = false;
@@ -20,9 +19,10 @@ class Pro6pp
2019
*
2120
* @param $api_key
2221
* @param $format
23-
* @param boolean $pretty
22+
* @param bool $pretty
2423
*/
25-
public function __construct($api_key, $format = 'json', $pretty = false) {
24+
public function __construct($api_key, $format = 'json', $pretty = false)
25+
{
2626
$this->api_key = $api_key;
2727
$this->api_format = $format;
2828
$this->api_pretty = $pretty;
@@ -31,7 +31,8 @@ public function __construct($api_key, $format = 'json', $pretty = false) {
3131
/**
3232
* @return string
3333
*/
34-
public function getApikey() {
34+
public function getApikey()
35+
{
3536
return $this->api_key;
3637
}
3738

@@ -44,7 +45,8 @@ public function getApikey() {
4445
*
4546
* @return mixed
4647
*/
47-
public function autocomplete($postalcode, $number = '', $extension = '') {
48+
public function autocomplete($postalcode, $number = '', $extension = '')
49+
{
4850
$postalcode = $this->determinePostalType($postalcode);
4951

5052
$this->data = array_merge($postalcode, ['streetnumber' => $number, 'extension' => $extension]);
@@ -60,7 +62,8 @@ public function autocomplete($postalcode, $number = '', $extension = '') {
6062
*
6163
* @return mixed
6264
*/
63-
public function reverse($lat, $lng) {
65+
public function reverse($lat, $lng)
66+
{
6467
$this->data = ['lat' => $lat, 'lng' => $lng];
6568

6669
return $this->call('reverse', $this->prepareData($this->data));
@@ -75,8 +78,9 @@ public function reverse($lat, $lng) {
7578
*
7679
* @return mixed
7780
*/
78-
public function locator($target_nl_fourpps, $optional = []) {
79-
$this->data['target_nl_fourpps'] = implode(",", $target_nl_fourpps);
81+
public function locator($target_nl_fourpps, $optional = [])
82+
{
83+
$this->data['target_nl_fourpps'] = implode(',', $target_nl_fourpps);
8084

8185
$this->data = array_merge($this->data, $optional);
8286

@@ -93,21 +97,23 @@ public function locator($target_nl_fourpps, $optional = []) {
9397
*
9498
* @return mixed
9599
*/
96-
public function range($nl_fourpp, $range = 5000, $per_page = 10, $page = 1) {
100+
public function range($nl_fourpp, $range = 5000, $per_page = 10, $page = 1)
101+
{
97102
$this->data = ['nl_fourpp' => $nl_fourpp, 'range' => $range, 'per_page' => $per_page, 'page' => $page];
98103

99104
return $this->call('range', $this->prepareData($this->data));
100105
}
101106

102107
/**
103-
* Autocompletes a city name
108+
* Autocompletes a city name.
104109
*
105110
* @param $nl_city
106111
* @param int $per_page
107112
*
108113
* @return mixed
109114
*/
110-
public function suggest($nl_city, $per_page = 10) {
115+
public function suggest($nl_city, $per_page = 10)
116+
{
111117
$this->data = ['nl_city' => $nl_city, 'per_page' => $per_page];
112118

113119
return $this->call('suggest', $this->prepareData($this->data));
@@ -123,7 +129,8 @@ public function suggest($nl_city, $per_page = 10) {
123129
*
124130
* @return mixed
125131
*/
126-
public function distance($from_nl_fourpp, $to_nl_fourpp, $algorithm = 'road') {
132+
public function distance($from_nl_fourpp, $to_nl_fourpp, $algorithm = 'road')
133+
{
127134
$this->data = ['from_nl_fourpp' => $from_nl_fourpp, 'to_nl_fourpp' => $to_nl_fourpp, 'algorithm' => $algorithm];
128135

129136
return $this->call('distance', $this->prepareData($this->data));
@@ -136,7 +143,6 @@ public function distance($from_nl_fourpp, $to_nl_fourpp, $algorithm = 'road') {
136143
* @param $lng1
137144
* @param $lat2
138145
* @param $lng2
139-
*
140146
* @param bool $miles
141147
*
142148
* @return float
@@ -157,26 +163,27 @@ public function coordinatesDistance($lat1, $lng1, $lat2, $lng2, $miles = false)
157163
$c = 2 * atan2(sqrt($a), sqrt(1 - $a));
158164
$km = $r * $c;
159165

160-
return ($miles ? ($km * 0.621371192) : $km);
166+
return $miles ? ($km * 0.621371192) : $km;
161167
}
162168

163169
/**
164170
* Checks if one of two valid postal types was sent along.
165171
*
166172
* @param $postalcode
167173
*
168-
* @return array
169-
*
170174
* @throws \Exception
175+
*
176+
* @return array
171177
*/
172-
public function determinePostalType($postalcode) {
173-
$postalcode = str_replace(" ", "", $postalcode);
178+
public function determinePostalType($postalcode)
179+
{
180+
$postalcode = str_replace(' ', '', $postalcode);
174181

175-
if(strlen($postalcode) == 6) {
182+
if (strlen($postalcode) == 6) {
176183
return ['nl_sixpp' => $postalcode];
177184
}
178185

179-
if(strlen($postalcode) == 4) {
186+
if (strlen($postalcode) == 4) {
180187
return ['nl_fourpp' => $postalcode];
181188
}
182189

@@ -190,7 +197,8 @@ public function determinePostalType($postalcode) {
190197
*
191198
* @return mixed
192199
*/
193-
protected function prepareData($data) {
200+
protected function prepareData($data)
201+
{
194202
$data['auth_key'] = $this->api_key;
195203
$data['format'] = $this->api_format;
196204
$data['pretty'] = $this->api_pretty;
@@ -207,8 +215,9 @@ protected function prepareData($data) {
207215
*
208216
* @return mixed
209217
*/
210-
protected function call($path, $data) {
211-
$url = $this->api_host . $path .'?'. http_build_query($data);
218+
protected function call($path, $data)
219+
{
220+
$url = $this->api_host.$path.'?'.http_build_query($data);
212221

213222
$ch = curl_init($url);
214223

@@ -221,5 +230,4 @@ protected function call($path, $data) {
221230

222231
return $return;
223232
}
224-
225233
}

tests/Pro6ppTest.php

Lines changed: 30 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,21 @@
44

55
class Pro6ppTest extends \PHPUnit\Framework\TestCase
66
{
7-
87
/**
9-
* Test if the API key gets set when constructing
8+
* Test if the API key gets set when constructing.
109
*/
11-
public function test_it_sets_api_key() {
10+
public function test_it_sets_api_key()
11+
{
1212
$pro6pp = new Pro6pp('api_key');
1313

1414
$this->assertEquals('api_key', $pro6pp->getApiKey());
1515
}
1616

1717
/**
18-
* Test if the autocomplete method works
18+
* Test if the autocomplete method works.
1919
*/
20-
public function test_it_autocompletes() {
20+
public function test_it_autocompletes()
21+
{
2122
$data = '{"status":"ok","results":[{"extension":"C","nl_sixpp":"6225XS","street":"Geusseltweg","city":"Maastricht","municipality":"Maastricht","province":"Limburg","lat":50.8579834,"lng":5.7174217,"areacode":"043","streetnumber":7}]}';
2223

2324
$stub = $this->createMock(Pro6pp::class);
@@ -29,9 +30,10 @@ public function test_it_autocompletes() {
2930
}
3031

3132
/**
32-
* Test if the reverse method works
33+
* Test if the reverse method works.
3334
*/
34-
public function test_it_reverses() {
35+
public function test_it_reverses()
36+
{
3537
$data = '{"status":"ok","results":{"precision":8,"province":"Limburg","municipality":"Maastricht","city":"Maastricht","nl_fourpp":6225,"lat":50.857970000000002,"lng":5.7173999999999996,"nl_sixpp":"6225XS","streets":["Geusseltweg"]}}';
3638

3739
$stub = $this->createMock(Pro6pp::class);
@@ -43,9 +45,10 @@ public function test_it_reverses() {
4345
}
4446

4547
/**
46-
* Test if the locator method works
48+
* Test if the locator method works.
4749
*/
48-
public function test_it_locates() {
50+
public function test_it_locates()
51+
{
4952
$data = '{"status":"ok","results":[{"nl_fourpp":6225,"distance":0,"lat":50.86277,"lng":5.73217,"city":"Maastricht","municipality":"Maastricht","province":"Limburg"},{"nl_fourpp":6223,"distance":3606,"lat":50.88435,"lng":5.69387,"city":"Maastricht","municipality":"Maastricht","province":"Limburg"}]}';
5053

5154
$stub = $this->createMock(Pro6pp::class);
@@ -57,9 +60,10 @@ public function test_it_locates() {
5760
}
5861

5962
/**
60-
* Test if the range method works
63+
* Test if the range method works.
6164
*/
62-
public function test_it_finds_within_range() {
65+
public function test_it_finds_within_range()
66+
{
6367
$data = '{"status":"ok","results":[{"nl_fourpp":"6225","distance":0,"lat":50.8628,"lng":5.7322},{"nl_fourpp":"6222","distance":1445,"lat":50.8659,"lng":5.7122}]}';
6468

6569
$stub = $this->createMock(Pro6pp::class);
@@ -71,9 +75,10 @@ public function test_it_finds_within_range() {
7175
}
7276

7377
/**
74-
* Test if the distance method works
78+
* Test if the distance method works.
7579
*/
76-
public function test_it_calculates_distance() {
80+
public function test_it_calculates_distance()
81+
{
7782
$data = '{"status":"ok","results":{"distance":4522}}';
7883

7984
$stub = $this->createMock(Pro6pp::class);
@@ -85,9 +90,10 @@ public function test_it_calculates_distance() {
8590
}
8691

8792
/**
88-
* Test if the suggest method works
93+
* Test if the suggest method works.
8994
*/
90-
public function test_it_suggests() {
95+
public function test_it_suggests()
96+
{
9197
$data = '{"status":"ok","results":[{"city_key":"agxlfnBybzZwcC1hcGlyHAsSDENpdHlTdWdnZXN0MiIKbWFhc2JvbW1lbAw","city":"Maasbommel","official_city":"Maasbommel","nl_fourpps":"6627","province":"Gelderland","lat":51.82719,"lng":5.53366}]}';
9298

9399
// Create a stub for the Pro6pp class.
@@ -101,27 +107,30 @@ public function test_it_suggests() {
101107
}
102108

103109
/**
104-
* Test if the distance between coordiantes method works
110+
* Test if the distance between coordiantes method works.
105111
*/
106-
public function test_it_calculates_distance_by_coordinates() {
112+
public function test_it_calculates_distance_by_coordinates()
113+
{
107114
$Pro6pp = new Pro6pp('api_key');
108115

109116
$this->assertEquals(4.5435663553281715, $Pro6pp->coordinatesDistance(50.858030, 5.717376, 50.840078, 5.659258));
110117
}
111118

112119
/**
113-
* Test to see if the code can determine a nl_fourpp postal
120+
* Test to see if the code can determine a nl_fourpp postal.
114121
*/
115-
public function test_it_can_determine_fourpp_postal() {
122+
public function test_it_can_determine_fourpp_postal()
123+
{
116124
$Pro6pp = new Pro6pp('api_key');
117125

118126
$this->assertEquals('6225', $Pro6pp->determinePostalType('6225')['nl_fourpp']);
119127
}
120128

121129
/**
122-
* Test to see if the code can determine a nl_fourpp postal
130+
* Test to see if the code can determine a nl_fourpp postal.
123131
*/
124-
public function test_it_can_determine_sixpp_postal() {
132+
public function test_it_can_determine_sixpp_postal()
133+
{
125134
$Pro6pp = new Pro6pp('api_key');
126135

127136
$this->assertEquals('6225XS', $Pro6pp->determinePostalType('6225XS')['nl_sixpp']);

0 commit comments

Comments
 (0)