Skip to content

Commit 35d358f

Browse files
authored
Merge pull request #12 from jmarcher/analysis-0ggVae
Apply fixes from StyleCI
2 parents ad038b6 + 095e494 commit 35d358f

File tree

4 files changed

+24
-28
lines changed

4 files changed

+24
-28
lines changed

src/ApiModel.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ public function __set($key, $value)
183183
}
184184
}
185185

186-
protected function hasRelationship($key): ? string
186+
protected function hasRelationship($key): ?string
187187
{
188188
if (method_exists($this, $key)
189189
&& ($this->{$key}() instanceof Relationship || $this->{$key}() instanceof SingleRelationship)) {
@@ -226,7 +226,7 @@ public function __get($key)
226226
*
227227
* @return bool
228228
*/
229-
public function exists() : bool
229+
public function exists(): bool
230230
{
231231
foreach ($this->requiredParameters as $parameter) {
232232
if (!$this->has($parameter)) {

src/Relationships/SingleRelationship.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ public function setRelateClassQualifiedName(string $class)
1515
return $this;
1616
}
1717

18-
public function getRelatedClassQualifiedName():string
18+
public function getRelatedClassQualifiedName(): string
1919
{
2020
return $this->relatedClassQualifiedName;
2121
}

tests/Fakes/City.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ class City extends ApiModel
88
{
99
public function partnerCity()
1010
{
11-
return $this->hasOne(City::class, 'partner_city');
11+
return $this->hasOne(self::class, 'partner_city');
1212
}
1313
}

tests/ModelTest.php

Lines changed: 20 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,7 @@ public function it_should_assign_a_value_to_a_parameter()
4949
/** @test */
5050
public function it_should_throw_an_error_on_immutble_parameters()
5151
{
52-
$model = new class() extends ApiModel
53-
{
52+
$model = new class() extends ApiModel {
5453
public function getFooAttribute()
5554
{
5655
return 'bar';
@@ -66,8 +65,7 @@ public function getFooAttribute()
6665
/** @test */
6766
public function it_should_throw_an_error_on_immutble_methods()
6867
{
69-
$model = new class() extends ApiModel
70-
{
68+
$model = new class() extends ApiModel {
7169
public function fakeMethod(): string
7270
{
7371
return 'I return a string';
@@ -83,8 +81,7 @@ public function fakeMethod(): string
8381
/** @test */
8482
public function it_should_return_null_getting_value_on_defined_methods()
8583
{
86-
$model = new class() extends ApiModel
87-
{
84+
$model = new class() extends ApiModel {
8885
public function fakeMethod(): string
8986
{
9087
return 'I return a string';
@@ -157,7 +154,7 @@ public function it_should_cast_single_relationship_to_model()
157154
$harbor = new Harbor([
158155
'city' => [
159156
'data' => [
160-
'id' => 1,
157+
'id' => 1,
161158
'name' => 'Montevideo',
162159
],
163160
],
@@ -172,7 +169,7 @@ public function it_should_cast_single_relationship_to_model_and_preserve_attribu
172169
$harbor = new Harbor([
173170
'city' => [
174171
'data' => [
175-
'id' => 1,
172+
'id' => 1,
176173
'name' => 'Montevideo',
177174
],
178175
],
@@ -186,7 +183,7 @@ public function it_should_cast_single_relationship_to_model_event_without_data()
186183
{
187184
$harbor = new Harbor([
188185
'city' => [
189-
'id' => 1,
186+
'id' => 1,
190187
'name' => 'Montevideo',
191188
],
192189
]);
@@ -199,7 +196,7 @@ public function it_should_refresh_a_relationship_when_setting_new_value()
199196
{
200197
$harbor = new Harbor([
201198
'city' => [
202-
'id' => 1,
199+
'id' => 1,
203200
'name' => 'Montevideo',
204201
],
205202
]);
@@ -217,7 +214,7 @@ public function it_should_property_from_relationship_should_be_accessed()
217214
$harbor = new Harbor([
218215
'city' => [
219216
'data' => [
220-
'id' => 1,
217+
'id' => 1,
221218
'name' => 'Montevideo',
222219
],
223220
],
@@ -233,7 +230,7 @@ public function it_should_property_from_relationship_should_be_accessed_as_objec
233230
$harbor = new Harbor([
234231
'city' => [
235232
'data' => [
236-
'id' => 1,
233+
'id' => 1,
237234
'name' => 'Montevideo',
238235
],
239236
],
@@ -249,7 +246,7 @@ public function it_should_property_from_relationship_should_be_accessed_double()
249246
$harbor = new Harbor([
250247
'city' => [
251248
'data' => [
252-
'id' => 1,
249+
'id' => 1,
253250
'name' => 'Montevideo',
254251
],
255252
],
@@ -265,10 +262,10 @@ public function it_should_preserve_attributes_for_child_properties()
265262
$harbor = new Harbor([
266263
'city' => [
267264
'data' => [
268-
'id' => 1,
269-
'name' => 'Montevideo',
265+
'id' => 1,
266+
'name' => 'Montevideo',
270267
'partner_city' => [
271-
'id' => 2,
268+
'id' => 2,
272269
'name' => 'Berlin',
273270
],
274271
],
@@ -286,11 +283,11 @@ public function it_should_return_a_collection_of_boats()
286283
'boats' => [
287284
'data' => [
288285
[
289-
'id' => 1,
286+
'id' => 1,
290287
'name' => 'Queen Mary',
291288
],
292289
[
293-
'id' => 2,
290+
'id' => 2,
294291
'name' => 'Reconcho',
295292
],
296293
],
@@ -307,11 +304,11 @@ public function it_should_refresh_a_collection_of_relationships()
307304
'boats' => [
308305
'data' => [
309306
[
310-
'id' => 1,
307+
'id' => 1,
311308
'name' => 'Queen Mary',
312309
],
313310
[
314-
'id' => 2,
311+
'id' => 2,
315312
'name' => 'Reconcho',
316313
],
317314
],
@@ -340,9 +337,9 @@ public function it_should_eager_load_default_relationships()
340337
'visited_cities' => [
341338
'data' => [
342339
[
343-
'name' => 'Montevideo',
340+
'name' => 'Montevideo',
344341
'partner_city' => [
345-
'id' => 2,
342+
'id' => 2,
346343
'name' => 'Berlin',
347344
],
348345
],
@@ -360,8 +357,7 @@ public function it_should_eager_load_default_relationships()
360357
/** @test */
361358
public function it_should_not_eager_load_any_relationship_if_not_in_include_default_array()
362359
{
363-
$model = new class(['visited_cities' => ['data' => [['name' => 'Montevideo'], ['name' => 'London']]]]) extends ApiModel
364-
{
360+
$model = new class(['visited_cities' => ['data' => [['name' => 'Montevideo'], ['name' => 'London']]]]) extends ApiModel {
365361
public function visitedCities()
366362
{
367363
return $this->hasMany(City::class, 'visited_cities');

0 commit comments

Comments
 (0)