Skip to content

Commit

Permalink
Apply fixes from StyleCI
Browse files Browse the repository at this point in the history
  • Loading branch information
StyleCIBot authored and jiannei committed Dec 29, 2022
1 parent f60d5b6 commit eb17eb5
Show file tree
Hide file tree
Showing 6 changed files with 38 additions and 11 deletions.
15 changes: 12 additions & 3 deletions src/Contracts/Format.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<?php

/*
* This file is part of the jiannei/laravel-response.
*
* (c) Jiannei <[email protected]>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

namespace Jiannei\Response\Laravel\Contracts;

use Illuminate\Http\Resources\Json\JsonResource;
Expand All @@ -13,7 +22,7 @@ interface Format
*
* @param array|null $data
* @param string|null $message
* @param int $code
* @param int $code
* @param null $errors
* @return array
*/
Expand All @@ -37,7 +46,7 @@ public function statusCode($code): int;
* @param int $option
* @return array
*/
public function paginator(AbstractPaginator $resource, string $message = '', int $code = 200, array $headers = [], int $option = 0):array;
public function paginator(AbstractPaginator $resource, string $message = '', int $code = 200, array $headers = [], int $option = 0): array;

/**
* Format collection resource data.
Expand All @@ -62,4 +71,4 @@ public function resourceCollection(ResourceCollection $resource, string $message
* @return array
*/
public function jsonResource(JsonResource $resource, string $message = '', int $code = 200, array $headers = [], int $option = 0): array;
}
}
2 changes: 1 addition & 1 deletion src/Providers/LaravelServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function boot()
$format = $this->app['config']['response']['format'];

if (is_string($format) && class_exists($format)) {
$this->app->bind(\Jiannei\Response\Laravel\Support\Format::class,$format);
$this->app->bind(\Jiannei\Response\Laravel\Support\Format::class, $format);
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/Support/Format.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class Format implements \Jiannei\Response\Laravel\Contracts\Format
*
* @param array|null $data
* @param string|null $message
* @param int $code
* @param int $code
* @param null $errors
* @return array
*/
Expand Down
15 changes: 12 additions & 3 deletions tests/FormatTest.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<?php

/*
* This file is part of the jiannei/laravel-response.
*
* (c) Jiannei <[email protected]>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

namespace Jiannei\Response\Laravel\Tests;

use Jiannei\Response\Laravel\Support\Facades\Response;
Expand All @@ -12,7 +21,7 @@ public function testAddExtraField()

$this->assertEquals(200, $response->status());

$this->assertArrayHasKey('extra',$response->getData(true));
$this->assertArrayHasKey('time',$response->getData(true)['extra']);
$this->assertArrayHasKey('extra', $response->getData(true));
$this->assertArrayHasKey('time', $response->getData(true)['extra']);
}
}
}
13 changes: 11 additions & 2 deletions tests/Support/Format.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
<?php

/*
* This file is part of the jiannei/laravel-response.
*
* (c) Jiannei <[email protected]>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/

namespace Jiannei\Response\Laravel\Tests\Support;

use Illuminate\Support\Facades\Config;
Expand All @@ -19,8 +28,8 @@ public function data(?array $data, ?string $message, int $code, $errors = null):
'data' => $data ?: (object) $data,
'error' => $errors ?: (object) [],
'extra' => [
'time' => time()
'time' => time(),
],
], Config::get('response.format.fields', []));
}
}
}
2 changes: 1 addition & 1 deletion tests/TestCase.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,6 @@ protected function defineEnvironment($app)
]);

$app['config']->set('response.enum', \Jiannei\Response\Laravel\Tests\Repositories\Enums\ResponseCodeEnum::class);
$app['config']->set('response.format',\Jiannei\Response\Laravel\Tests\Support\Format::class);
$app['config']->set('response.format', \Jiannei\Response\Laravel\Tests\Support\Format::class);
}
}

0 comments on commit eb17eb5

Please sign in to comment.