Skip to content

Commit

Permalink
Revert "Rename resource interface" to prevent confusion with native
Browse files Browse the repository at this point in the history
resource type

This reverts commit d9e1f5f.
  • Loading branch information
Stratadox committed Feb 2, 2020
1 parent d9e1f5f commit b63f4d0
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 14 deletions.
2 changes: 1 addition & 1 deletion src/BasicResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Stratadox\RestResource;

final class BasicResource implements Resource
final class BasicResource implements RestResource
{
/** @var string */
private $name;
Expand Down
4 changes: 2 additions & 2 deletions src/CannotFormatJson.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

final class CannotFormatJson extends InvalidArgumentException implements Unformattable
{
public static function because(Resource $resource, Throwable $reason): self
public static function because(RestResource $resource, Throwable $reason): self
{
return new self(sprintf(
'Could not format the resource `%s` as json, because: %s',
Expand All @@ -17,7 +17,7 @@ public static function because(Resource $resource, Throwable $reason): self
), $reason->getCode(), $reason);
}

public static function jsonError(Resource $resource, string $error): self
public static function jsonError(RestResource $resource, string $error): self
{
return new self(sprintf(
'Could not format the resource `%s` as json, because: %s',
Expand Down
2 changes: 1 addition & 1 deletion src/CannotFormatXml.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

final class CannotFormatXml extends InvalidArgumentException implements Unformattable
{
public static function because(Resource $resource, Throwable $reason): self
public static function because(RestResource $resource, Throwable $reason): self
{
return new self(sprintf(
'Could not format the resource `%s` as xml, because: %s',
Expand Down
2 changes: 1 addition & 1 deletion src/DefaultJsonFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function __construct(string $baseUri)
$this->baseUri = $baseUri;
}

public function from(Resource $resource): string
public function from(RestResource $resource): string
{
try {
$result = json_encode([
Expand Down
2 changes: 1 addition & 1 deletion src/LinkRetrieval.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

trait LinkRetrieval
{
private function linksOf(Resource $resource, string $baseUri): array
private function linksOf(RestResource $resource, string $baseUri): array
{
if (!count($resource->links())) {
return [];
Expand Down
4 changes: 2 additions & 2 deletions src/ResourceFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ interface ResourceFormatter
/**
* Formats a response based on a rest resource.
*
* @param Resource $resource The resource to format.
* @param RestResource $resource The resource to format.
* @return string The presentable output.
* @throws Unformattable When the resource cannot be formatted.
*/
public function from(Resource $resource): string;
public function from(RestResource $resource): string;
}
2 changes: 1 addition & 1 deletion src/Resource.php → src/RestResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace Stratadox\RestResource;

interface Resource
interface RestResource
{
/**
* Retrieves the body or the resource.
Expand Down
2 changes: 1 addition & 1 deletion src/XmlFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static function in(
return new static($baseUri, BoogieSingularizer::in($locale));
}

public function from(Resource $resource): string
public function from(RestResource $resource): string
{
$xml = new SimpleXMLElement(sprintf(
'<?xml version="1.0"?><%s />',
Expand Down
4 changes: 2 additions & 2 deletions tests/Fixture/HateoasResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
namespace Stratadox\RestResource\Test\Fixture;

use Stratadox\RestResource\Links;
use Stratadox\RestResource\Resource;
use Stratadox\RestResource\RestResource;

final class HateoasResource implements Resource
final class HateoasResource implements RestResource
{
/** @var array */
private $body;
Expand Down
4 changes: 2 additions & 2 deletions tests/Fixture/MinimalResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
namespace Stratadox\RestResource\Test\Fixture;

use Stratadox\RestResource\Links;
use Stratadox\RestResource\Resource;
use Stratadox\RestResource\RestResource;

final class MinimalResource implements Resource
final class MinimalResource implements RestResource
{
/** @var array */
private $body;
Expand Down

0 comments on commit b63f4d0

Please sign in to comment.