Skip to content

Commit 7be70ef

Browse files
committed
Improve code
1 parent 82c99e2 commit 7be70ef

File tree

6 files changed

+18
-15
lines changed

6 files changed

+18
-15
lines changed

src/Lodash/Http/Resources/JsonResource.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,11 @@ public function appendAdditional(array $data): self
9595
return $this;
9696
}
9797

98+
public function jsonOptions(): int
99+
{
100+
return JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE;
101+
}
102+
98103
protected function getResourceData(): array
99104
{
100105
if ($this->resource instanceof TransformableContract) {
@@ -188,9 +193,4 @@ private static function undot(array $array): array
188193

189194
return $result;
190195
}
191-
192-
public function jsonOptions(): int
193-
{
194-
return JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE;
195-
}
196196
}

src/Lodash/Http/Resources/JsonResourceCollection.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,11 @@ public function appendAdditional(array $data): self
4242
return $this;
4343
}
4444

45+
public function jsonOptions(): int
46+
{
47+
return JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE;
48+
}
49+
4550
protected function preparePaginatedResponse($request)
4651
{
4752
if ($this->preserveAllQueryParameters) {
@@ -52,9 +57,4 @@ protected function preparePaginatedResponse($request)
5257

5358
return (new PaginatedResourceResponse($this))->toResponse($request);
5459
}
55-
56-
public function jsonOptions(): int
57-
{
58-
return JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE;
59-
}
6060
}

src/Lodash/ServiceProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ protected function loadValidations(): void
138138
}
139139

140140
Validator::extend('type', function ($attribute, $value, $parameters, $validator): bool {
141-
$validator->addReplacer('type', function ($message, $attribute, $rule, $parameters): string {
141+
$validator->addReplacer('type', static function ($message, $attribute, $rule, $parameters): string {
142142
return str_replace(':type', $parameters[0], $message);
143143
});
144144

src/Lodash/Validation/StrictTypesValidator.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
namespace Longman\LaravelLodash\Validation;
66

7+
use function gettype;
8+
use function in_array;
9+
710
readonly class StrictTypesValidator
811
{
912
protected const NATIVE_TYPE_INT = 'integer';

tests/Bootstrap.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,13 +12,13 @@
1212
*/
1313
date_default_timezone_set('UTC');
1414

15-
$root = realpath(dirname(dirname(__FILE__)));
15+
$root = realpath(__DIR__);
1616
/**
1717
* Check that --dev composer installation was done
1818
*/
1919
if (! file_exists($root . '/vendor/autoload.php')) {
2020
throw new Exception(
21-
'Please run "php composer.phar install --dev" in root directory
21+
'Please run "php composer.phar install --dev" in root directory
2222
to setup unit test dependencies before running the tests',
2323
);
2424
}

tests/Unit/TestCase.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@
77
use Longman\LaravelLodash\Cache\CacheServiceProvider;
88
use Longman\LaravelLodash\Debug\DebugServiceProvider;
99
use Longman\LaravelLodash\Elasticsearch\ElasticsearchServiceProvider;
10-
use Longman\LaravelLodash\ServiceProvider;
1110
use Longman\LaravelLodash\Queue\QueueServiceProvider;
1211
use Longman\LaravelLodash\Redis\RedisServiceProvider;
12+
use Longman\LaravelLodash\ServiceProvider;
1313
use Orchestra\Testbench\TestCase as BaseTestCase;
1414

1515
class TestCase extends BaseTestCase
1616
{
17-
protected function getPackageProviders($app)
17+
protected function getPackageProviders($app): array
1818
{
1919
return [
2020
ServiceProvider::class,

0 commit comments

Comments
 (0)