Skip to content

Commit 54e85de

Browse files
committed
Drop Interface suffix
1 parent 5c60a46 commit 54e85de

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+224
-215
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,17 @@ and this project adheres to
88

99
## [Unreleased]
1010

11+
### ⚠️ Breaking Changes
12+
13+
- Drop `Interface` suffix from various interfaces:
14+
- `Resource` class renamed to `AbstractResource`
15+
- `ResourceInterface` renamed to `Resource`
16+
- `CollectionInterface` renamed to `Collection`
17+
- `ErrorProviderInterface` renamed to `ErrorProvider`
18+
- `PaginationInterface` renamed to `Pagination`
19+
- `EndpointInterface` renamed to `Endpoint`
20+
- `TypeInterface` renamed to `Type`
21+
1122
## [1.0.0-beta.2] - 2023-12-02
1223

1324
### ⚠️ Breaking Changes

docs/collections.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@ also used for defining
1111
## Defining Collections
1212

1313
To define a heterogeneous collection, create a new class that implements
14-
`Tobyz\JsonApi\Resource\CollectionInterface`:
14+
`Tobyz\JsonApi\Resource\Collection`:
1515

1616
```php
17-
use Tobyz\JsonApiServer\Resource\CollectionInterface;
17+
use Tobyz\JsonApiServer\Resource\Collection;
1818

19-
class ActivityCollection implements CollectionInterface
19+
class ActivityCollection implements Collection
2020
{
2121
/**
2222
* Get the collection name.

docs/context.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ class Context
1717
public ServerRequestInterface $request;
1818

1919
// The collection that the request is for
20-
public ?CollectionInterface $collection = null;
20+
public ?Collection $collection = null;
2121

2222
// The resource that the request is for
23-
public ?ResourceInterface $resource = null;
23+
public ?Resource $resource = null;
2424

2525
// The endpoint handling the request
26-
public ?EndpointInterface $endpoint = null;
26+
public ?Endpoint $endpoint = null;
2727

2828
// The query being constructed by the Index endpoint
2929
public ?object $query = null;
@@ -54,13 +54,13 @@ class Context
5454
public function body(): ?array;
5555

5656
// Get a resource by type
57-
public function resource(string $type): ResourceInterface;
57+
public function resource(string $type): Resource;
5858

5959
// Get the fields for the given resource, keyed by name
60-
public function fields(ResourceInterface $resource): array;
60+
public function fields(Resource $resource): array;
6161

6262
// Get only the requested fields for the given resource
63-
public function sparseFields(ResourceInterface $resource): array;
63+
public function sparseFields(Resource $resource): array;
6464

6565
// Determine whether a field has been requested in a sparse fieldset
6666
public function fieldRequested(string $type, string $field, bool $default = true): bool;

docs/errors.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ try {
1515

1616
## Error Providers
1717

18-
Exceptions can implement `Tobyz\JsonApiServer\Exception\ErrorProviderInterface`
19-
to determine what status code will be used in the response, and any JSON:API
20-
error objects to be rendered in the document.
18+
Exceptions can implement the `Tobyz\JsonApiServer\Exception\ErrorProvider`
19+
interface to determine what status code will be used in the response, and any
20+
JSON:API error objects to be rendered in the document.
2121

2222
The interface defines two methods:
2323

@@ -26,9 +26,9 @@ The interface defines two methods:
2626

2727
```php
2828
use JsonApiPhp\JsonApi\Error;
29-
use Tobyz\JsonApiServer\Exception\ErrorProviderInterface;
29+
use Tobyz\JsonApiServer\Exception\ErrorProvider;
3030

31-
class ImATeapotException implements ErrorProviderInterface
31+
class ImATeapotException implements ErrorProvider
3232
{
3333
public function getJsonApiErrors(): array
3434
{

docs/list.md

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,9 @@ An example implementation might look like:
4747
```php
4848
use App\Models\Post;
4949
use Tobyz\JsonApiServer\Context;
50-
use Tobyz\JsonApiServer\Resource\{Listable, Resource};
50+
use Tobyz\JsonApiServer\Resource\{Listable, AbstractResource};
5151

52-
class PostsResource extends Resource implements Listable
52+
class PostsResource extends AbstractResource implements Listable
5353
{
5454
// ...
5555

@@ -284,9 +284,9 @@ applied to your query:
284284
```php
285285
use Tobyz\JsonApiServer\Context;
286286
use Tobyz\JsonApiServer\Pagination\OffsetPagination;
287-
use Tobyz\JsonApiServer\Resource\{Listable, Paginatable, Resource};
287+
use Tobyz\JsonApiServer\Resource\{Listable, Paginatable, AbstractResource};
288288

289-
class PostsResource extends Resource implements Listable, Paginatable
289+
class PostsResource extends AbstractResource implements Listable, Paginatable
290290
{
291291
// ...
292292

@@ -309,9 +309,17 @@ of resources as `meta` information, you can implement the
309309
```php
310310
use Tobyz\JsonApiServer\Context;
311311
use Tobyz\JsonApiServer\Pagination\OffsetPagination;
312-
use Tobyz\JsonApiServer\Resource\{Countable, Listable, Paginatable, Resource};
313-
314-
class PostsResource extends Resource implements Listable, Paginatable, Countable
312+
use Tobyz\JsonApiServer\Resource\{
313+
Countable,
314+
Listable,
315+
Paginatable,
316+
AbstractResource,
317+
};
318+
319+
class PostsResource extends AbstractResource implements
320+
Listable,
321+
Paginatable,
322+
Countable
315323
{
316324
// ...
317325

docs/resources.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ the name of your resource type. This will also be used as the collection path
3131
for your resource.
3232

3333
```php
34-
use Tobyz\JsonApiServer\Resource\Resource;
34+
use Tobyz\JsonApiServer\Resource\AbstractResource;
3535

36-
class PostsResource extends Resource
36+
class PostsResource extends AbstractResource
3737
{
3838
public function type(): string
3939
{

src/Context.php

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@
33
namespace Tobyz\JsonApiServer;
44

55
use Psr\Http\Message\ServerRequestInterface;
6-
use Tobyz\JsonApiServer\Endpoint\EndpointInterface;
7-
use Tobyz\JsonApiServer\Resource\CollectionInterface;
8-
use Tobyz\JsonApiServer\Resource\ResourceInterface;
6+
use Tobyz\JsonApiServer\Endpoint\Endpoint;
7+
use Tobyz\JsonApiServer\Resource\Collection;
8+
use Tobyz\JsonApiServer\Resource\Resource;
99
use Tobyz\JsonApiServer\Schema\Field\Field;
1010
use WeakMap;
1111

1212
class Context
1313
{
14-
public ?CollectionInterface $collection = null;
15-
public ?ResourceInterface $resource = null;
16-
public ?EndpointInterface $endpoint = null;
14+
public ?Collection $collection = null;
15+
public ?Resource $resource = null;
16+
public ?Endpoint $endpoint = null;
1717
public ?object $query = null;
1818
public ?Serializer $serializer = null;
1919
public mixed $model = null;
@@ -72,7 +72,7 @@ public function body(): ?array
7272
/**
7373
* Get a resource by its type.
7474
*/
75-
public function resource(string $type): ResourceInterface
75+
public function resource(string $type): Resource
7676
{
7777
return $this->api->getResource($type);
7878
}
@@ -82,7 +82,7 @@ public function resource(string $type): ResourceInterface
8282
*
8383
* @return array<string, Field>
8484
*/
85-
public function fields(ResourceInterface $resource): array
85+
public function fields(Resource $resource): array
8686
{
8787
if (isset($this->fields[$resource])) {
8888
return $this->fields[$resource];
@@ -102,7 +102,7 @@ public function fields(ResourceInterface $resource): array
102102
*
103103
* @return array<string, Field>
104104
*/
105-
public function sparseFields(ResourceInterface $resource): array
105+
public function sparseFields(Resource $resource): array
106106
{
107107
if (isset($this->sparseFields[$resource])) {
108108
return $this->sparseFields[$resource];
@@ -157,21 +157,21 @@ public function withRequest(ServerRequestInterface $request): static
157157
return $new;
158158
}
159159

160-
public function withCollection(CollectionInterface $collection): static
160+
public function withCollection(Collection $collection): static
161161
{
162162
$new = clone $this;
163163
$new->collection = $collection;
164164
return $new;
165165
}
166166

167-
public function withResource(ResourceInterface $resource): static
167+
public function withResource(Resource $resource): static
168168
{
169169
$new = clone $this;
170170
$new->resource = $resource;
171171
return $new;
172172
}
173173

174-
public function withEndpoint(EndpointInterface $endpoint): static
174+
public function withEndpoint(Endpoint $endpoint): static
175175
{
176176
$new = clone $this;
177177
$new->endpoint = $endpoint;

src/Endpoint/Create.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
use function Tobyz\JsonApiServer\json_api_response;
1717
use function Tobyz\JsonApiServer\set_value;
1818

19-
class Create implements EndpointInterface
19+
class Create implements Endpoint
2020
{
2121
use HasVisibility;
2222
use SavesData;

src/Endpoint/Delete.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
use function Tobyz\JsonApiServer\json_api_response;
1717

18-
class Delete implements EndpointInterface
18+
class Delete implements Endpoint
1919
{
2020
use HasMeta;
2121
use HasVisibility;

src/Endpoint/EndpointInterface.php renamed to src/Endpoint/Endpoint.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use Psr\Http\Message\ResponseInterface as Response;
66
use Tobyz\JsonApiServer\Context;
77

8-
interface EndpointInterface
8+
interface Endpoint
99
{
1010
public function handle(Context $context): ?Response;
1111
}

src/Endpoint/Index.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
use function Tobyz\JsonApiServer\json_api_response;
2323
use function Tobyz\JsonApiServer\parse_sort_string;
2424

25-
class Index implements EndpointInterface
25+
class Index implements Endpoint
2626
{
2727
use HasMeta;
2828
use HasVisibility;

src/Endpoint/Show.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
use function Tobyz\JsonApiServer\json_api_response;
1414

15-
class Show implements EndpointInterface
15+
class Show implements Endpoint
1616
{
1717
use HasVisibility;
1818
use FindsResources;

src/Endpoint/Update.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
use function Tobyz\JsonApiServer\json_api_response;
1717

18-
class Update implements EndpointInterface
18+
class Update implements Endpoint
1919
{
2020
use HasVisibility;
2121
use FindsResources;

src/Exception/BadRequestException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use DomainException;
66
use Tobyz\JsonApiServer\Exception\Concerns\SingleError;
77

8-
class BadRequestException extends DomainException implements ErrorProviderInterface, Sourceable
8+
class BadRequestException extends DomainException implements ErrorProvider, Sourceable
99
{
1010
use SingleError;
1111

src/Exception/ConflictException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use DomainException;
66
use Tobyz\JsonApiServer\Exception\Concerns\SingleError;
77

8-
class ConflictException extends DomainException implements ErrorProviderInterface, Sourceable
8+
class ConflictException extends DomainException implements ErrorProvider, Sourceable
99
{
1010
use SingleError;
1111

src/Exception/ErrorProviderInterface.php renamed to src/Exception/ErrorProvider.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Tobyz\JsonApiServer\Exception;
44

5-
interface ErrorProviderInterface
5+
interface ErrorProvider
66
{
77
/**
88
* Get JSON:API error objects that represent this error.

src/Exception/ForbiddenException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use DomainException;
66
use Tobyz\JsonApiServer\Exception\Concerns\SingleError;
77

8-
class ForbiddenException extends DomainException implements ErrorProviderInterface, Sourceable
8+
class ForbiddenException extends DomainException implements ErrorProvider, Sourceable
99
{
1010
use SingleError;
1111

src/Exception/InternalServerErrorException.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
use RuntimeException;
66
use Tobyz\JsonApiServer\Exception\Concerns\SingleError;
77

8-
class InternalServerErrorException extends RuntimeException implements
9-
ErrorProviderInterface,
10-
Sourceable
8+
class InternalServerErrorException extends RuntimeException implements ErrorProvider, Sourceable
119
{
1210
use SingleError;
1311

src/Exception/MethodNotAllowedException.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
use DomainException;
66
use Tobyz\JsonApiServer\Exception\Concerns\SingleError;
77

8-
class MethodNotAllowedException extends DomainException implements
9-
ErrorProviderInterface,
10-
Sourceable
8+
class MethodNotAllowedException extends DomainException implements ErrorProvider, Sourceable
119
{
1210
use SingleError;
1311

src/Exception/NotAcceptableException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use DomainException;
66
use Tobyz\JsonApiServer\Exception\Concerns\SingleError;
77

8-
class NotAcceptableException extends DomainException implements ErrorProviderInterface, Sourceable
8+
class NotAcceptableException extends DomainException implements ErrorProvider, Sourceable
99
{
1010
use SingleError;
1111

src/Exception/NotFoundException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use DomainException;
66
use Tobyz\JsonApiServer\Exception\Concerns\SingleError;
77

8-
class NotFoundException extends DomainException implements ErrorProviderInterface, Sourceable
8+
class NotFoundException extends DomainException implements ErrorProvider, Sourceable
99
{
1010
use SingleError;
1111

src/Exception/NotImplementedException.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
use DomainException;
66
use Tobyz\JsonApiServer\Exception\Concerns\SingleError;
77

8-
class NotImplementedException extends DomainException implements ErrorProviderInterface, Sourceable
8+
class NotImplementedException extends DomainException implements ErrorProvider, Sourceable
99
{
1010
use SingleError;
1111

src/Exception/ResourceNotFoundException.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
use DomainException;
66
use Tobyz\JsonApiServer\Exception\Concerns\SingleError;
77

8-
class ResourceNotFoundException extends DomainException implements
9-
ErrorProviderInterface,
10-
Sourceable
8+
class ResourceNotFoundException extends DomainException implements ErrorProvider, Sourceable
119
{
1210
use SingleError;
1311

src/Exception/UnprocessableEntityException.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,7 @@
44

55
use DomainException;
66

7-
class UnprocessableEntityException extends DomainException implements
8-
ErrorProviderInterface,
9-
Sourceable
7+
class UnprocessableEntityException extends DomainException implements ErrorProvider, Sourceable
108
{
119
public function __construct(public array $errors)
1210
{

src/Exception/UnsupportedMediaTypeException.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
use DomainException;
66
use Tobyz\JsonApiServer\Exception\Concerns\SingleError;
77

8-
class UnsupportedMediaTypeException extends DomainException implements
9-
ErrorProviderInterface,
10-
Sourceable
8+
class UnsupportedMediaTypeException extends DomainException implements ErrorProvider, Sourceable
119
{
1210
use SingleError;
1311

0 commit comments

Comments
 (0)