This repository was archived by the owner on Feb 14, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 6 files changed +25
-23
lines changed Expand file tree Collapse file tree 6 files changed +25
-23
lines changed Original file line number Diff line number Diff line change @@ -13,14 +13,14 @@ public function jsonPaginate()
1313 * Paginate the given query using JSON:API.
1414 *
1515 * @param int|string $perPage
16- * @param array $columns
16+ * @param array $columns
1717 *
1818 * @return \Illuminate\Contracts\Pagination\LengthAwarePaginator
1919 */
2020 return function ($ perPage = null , $ columns = ['* ' ]) {
2121 $ perPage = $ perPage ?: $ this ->model ->getPerPage ();
2222 $ clientPerPage = (int ) request ('page.size ' , config ('json-api.pagination.default_size ' ));
23-
23+
2424 if (!$ perPage || $ perPage < $ clientPerPage ) {
2525 $ perPage = $ clientPerPage ;
2626 }
Original file line number Diff line number Diff line change @@ -6,8 +6,8 @@ interface JsonApiable
66{
77 /**
88 * Get a custom resource type for JSON:API formatting.
9- *
10- * @return string
9+ *
10+ * @return string
1111 */
1212 public function resourceType (): string ;
1313}
Original file line number Diff line number Diff line change 44
55use Illuminate \Contracts \Pagination \LengthAwarePaginator ;
66use Illuminate \Support \Collection ;
7+ use Illuminate \Support \Str ;
78use SkoreLabs \JsonApi \Contracts \JsonApiable ;
89use SkoreLabs \JsonApi \Http \Resources \JsonApiCollection ;
910use SkoreLabs \JsonApi \Http \Resources \JsonApiResource ;
10- use Illuminate \Support \Str ;
1111
1212class JsonApi
1313{
1414 /**
1515 * Format the input contents to JSON:API.
16- *
17- * @param mixed $value
18- * @return \SkoreLabs\JsonApi\Http\Resources\JsonApiResource
16+ *
17+ * @param mixed $value
18+ *
19+ * @return \SkoreLabs\JsonApi\Http\Resources\JsonApiResource
1920 */
2021 public static function format ($ value )
2122 {
@@ -28,9 +29,10 @@ public static function format($value)
2829
2930 /**
3031 * Get resource type from a model.
31- *
32- * @param \Illuminate\Database\Eloquent\Model|string $model
33- * @return string
32+ *
33+ * @param \Illuminate\Database\Eloquent\Model|string $model
34+ *
35+ * @return string
3436 */
3537 public static function getResourceType ($ model )
3638 {
Original file line number Diff line number Diff line change 66use Illuminate \Support \Traits \Macroable ;
77use PHPUnit \Framework \Assert as PHPUnit ;
88use PHPUnit \Framework \AssertionFailedError ;
9- use SkoreLabs \JsonApi \Testing \Concerns \HasRelationships ;
109use SkoreLabs \JsonApi \Testing \Concerns \HasAttributes ;
1110use SkoreLabs \JsonApi \Testing \Concerns \HasCollections ;
1211use SkoreLabs \JsonApi \Testing \Concerns \HasIdentifications ;
12+ use SkoreLabs \JsonApi \Testing \Concerns \HasRelationships ;
1313
1414class Assert implements Arrayable
1515{
16- use HasIdentifications,
17- HasAttributes,
18- HasRelationships,
19- HasCollections,
20- Macroable;
16+ use HasIdentifications;
17+ use HasAttributes;
18+ use HasRelationships;
19+ use HasCollections;
20+ use Macroable;
2121
2222 /**
2323 * @var string
@@ -38,7 +38,7 @@ class Assert implements Arrayable
3838 * @var array
3939 */
4040 protected $ relationships ;
41-
41+
4242 /**
4343 * @var array
4444 */
@@ -68,7 +68,7 @@ public static function fromTestResponse($response)
6868 PHPUnit::assertArrayHasKey ('data ' , $ content );
6969 $ data = $ content ['data ' ];
7070 $ collection = [];
71-
71+
7272 if (static ::isCollection ($ data )) {
7373 $ collection = $ data ;
7474 $ data = head ($ data );
Original file line number Diff line number Diff line change @@ -63,14 +63,14 @@ public function testCollectionsAtHasAttribute()
6363 $ json ->at (1 )->hasAttribute ('title ' , 'Test Title 2 ' );
6464 });
6565 }
66-
66+
6767 public function testCollectionsTakeByDefaultFirstItem ()
6868 {
6969 $ this ->get ('/ ' , ['Accept ' => 'application/json ' ])->assertJsonApi (function (Assert $ json ) {
7070 $ json ->hasAttribute ('title ' , 'Test Title ' );
7171 });
7272 }
73-
73+
7474 public function testCollectionsHasSize ()
7575 {
7676 $ this ->get ('/ ' , ['Accept ' => 'application/json ' ])->assertJsonApi (function (Assert $ json ) {
Original file line number Diff line number Diff line change @@ -31,13 +31,13 @@ public function setUp(): void
3131
3232 protected function defineDatabaseMigrations ()
3333 {
34- $ this ->loadMigrationsFrom (__DIR__ . '/database/migrations ' );
34+ $ this ->loadMigrationsFrom (__DIR__ . '/database/migrations ' );
3535 }
3636
3737 public function testJsonApiPaginationWithPageSize ()
3838 {
3939 $ response = $ this ->getJson ('/posts?page[size]=2 ' );
40-
40+
4141 $ response ->assertJsonApi (function (Assert $ json ) {
4242 $ json ->hasSize (2 );
4343 });
You can’t perform that action at this time.
0 commit comments