Skip to content
This repository was archived by the owner on Jan 29, 2020. It is now read-only.

Commit 87378c1

Browse files
replaced DepthAwareMetadataInterface with MetadataInterface
1 parent ef832d6 commit 87378c1

File tree

5 files changed

+13
-15
lines changed

5 files changed

+13
-15
lines changed

src/Metadata/AbstractMetadata.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99

1010
use Zend\Expressive\Hal\LinkCollection;
1111

12-
abstract class AbstractMetadata
12+
abstract class AbstractMetadata implements MetadataInterface
1313
{
1414
use LinkCollection;
1515

@@ -22,4 +22,9 @@ public function getClass() : string
2222
{
2323
return $this->class;
2424
}
25+
26+
public function hasReachedMaxDepth(int $currentDepth): bool
27+
{
28+
return false;
29+
}
2530
}

src/Metadata/DepthAwareMetadataInterface.php renamed to src/Metadata/MetadataInterface.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33

44
namespace Zend\Expressive\Hal\Metadata;
55

6-
interface DepthAwareMetadataInterface
6+
interface MetadataInterface
77
{
88
/**
9-
* Returns configured max depth
9+
* Returns the configured metadata class name
1010
*
11-
* @return int
11+
* @return string
1212
*/
13-
public function getMaxDepth(): int;
13+
public function getClass() : string;
1414

1515
/**
1616
* Determines whenever the current depth level exceeds the allowed max depth

src/Metadata/RouteBasedResourceMetadata.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
namespace Zend\Expressive\Hal\Metadata;
99

10-
class RouteBasedResourceMetadata extends AbstractResourceMetadata implements DepthAwareMetadataInterface
10+
class RouteBasedResourceMetadata extends AbstractResourceMetadata
1111
{
1212
/** @var string */
1313
private $resourceIdentifier;
@@ -67,11 +67,6 @@ public function setRouteParams(array $routeParams) : void
6767
$this->routeParams = $routeParams;
6868
}
6969

70-
public function getMaxDepth(): int
71-
{
72-
return $this->maxDepth;
73-
}
74-
7570
public function hasReachedMaxDepth(int $currentDepth): bool
7671
{
7772
return $currentDepth > $this->maxDepth;

src/ResourceGenerator/ExtractInstanceTrait.php

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@
1010
use Psr\Http\Message\ServerRequestInterface;
1111
use Zend\Expressive\Hal\Metadata\AbstractCollectionMetadata;
1212
use Zend\Expressive\Hal\Metadata\AbstractMetadata;
13-
use Zend\Expressive\Hal\Metadata\DepthAwareMetadataInterface;
14-
use Zend\Expressive\Hal\Metadata\RouteBasedResourceMetadata;
1513
use Zend\Expressive\Hal\ResourceGenerator;
1614
use Zend\Hydrator\ExtractionInterface;
1715

@@ -40,7 +38,7 @@ private function extractInstance(
4038

4139
$array = $extractor->extract($instance);
4240

43-
if ($metadata instanceof DepthAwareMetadataInterface && $metadata->hasReachedMaxDepth($depth)) {
41+
if ($metadata->hasReachedMaxDepth($depth)) {
4442
return $array;
4543
}
4644

src/ResourceGenerator/RouteBasedResourceStrategy.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function createResource(
4747
$routeParams[$routeIdentifier] = $data[$resourceIdentifier];
4848
}
4949

50-
if ($metadata instanceof Metadata\DepthAwareMetadataInterface && $metadata->hasReachedMaxDepth($depth)) {
50+
if ($metadata->hasReachedMaxDepth($depth)) {
5151
$data = [];
5252
}
5353

0 commit comments

Comments
 (0)