Skip to content

Commit

Permalink
Merge pull request #289 from bburnichon/improvement/always-call-with-…
Browse files Browse the repository at this point in the history
…parambag

Always returns a ParamBag
  • Loading branch information
philsturgeon authored Jul 21, 2016
2 parents d064765 + efb4366 commit 56ad893
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 10 deletions.
8 changes: 2 additions & 6 deletions src/Manager.php
Original file line number Diff line number Diff line change
Expand Up @@ -98,15 +98,11 @@ public function createData(ResourceInterface $resource, $scopeIdentifier = null,
*
* @param string $include
*
* @return \League\Fractal\ParamBag|null
* @return \League\Fractal\ParamBag
*/
public function getIncludeParams($include)
{
if (! isset($this->includeParams[$include])) {
return;
}

$params = $this->includeParams[$include];
$params = isset($this->includeParams[$include]) ? $this->includeParams[$include] : [];

return new ParamBag($params);
}
Expand Down
8 changes: 4 additions & 4 deletions src/TransformerAbstract.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
use League\Fractal\Resource\Collection;
use League\Fractal\Resource\Item;
use League\Fractal\Resource\NullResource;
use League\Fractal\Resource\ResourceAbstract;
use League\Fractal\Resource\ResourceInterface;

/**
* Transformer Abstract
Expand Down Expand Up @@ -188,13 +188,13 @@ protected function callIncludeMethod(Scope $scope, $includeName, $data)
return false;
}

if (! $resource instanceof ResourceAbstract) {
if (! $resource instanceof ResourceInterface) {
throw new \Exception(sprintf(
'Invalid return value from %s::%s(). Expected %s, received %s.',
__CLASS__,
$methodName,
'League\Fractal\Resource\ResourceAbstract',
gettype($resource)
'League\Fractal\Resource\ResourceInterface',
is_object($resource) ? get_class($resource) : gettype($resource)
));
}

Expand Down

0 comments on commit 56ad893

Please sign in to comment.