Skip to content
Permalink
Browse files

refactor: Some clean up to collection code.

  • Loading branch information...
tarlepp committed Nov 8, 2019
1 parent 629d6df commit d810d2e8b5da46fdc7a3a91377dccc1e6c3ff37d
Showing with 10 additions and 10 deletions.
  1. +1 −1 src/Collection/CollectionTrait.php
  2. +6 −6 src/Resource/ResourceCollection.php
  3. +3 −3 src/Rest/ControllerCollection.php
@@ -79,7 +79,7 @@ public function getAll(): IteratorAggregate
*/
public function has(?string $className = null): bool
{
return $this->getFilteredItem((string)$className) !== null;
return $className === null ? false : $this->getFilteredItem($className) !== null;
}
/**
@@ -66,24 +66,24 @@ public function getEntityResource(string $className): ?RestResourceInterface
}
/**
* @param string $className
* @param string|null $className
*
* @return bool
*/
public function hasEntityResource(?string $className): bool
public function hasEntityResource(?string $className = null): bool
{
return $this->getFilteredItemByEntity((string)$className) !== null;
return $className === null ? false : $this->getFilteredItemByEntity($className) !== null;
}
/**
* @param string|null $className
* @param string $className
*
* @return Closure
*/
public function filter(?string $className): Closure
public function filter(string $className): Closure
{
return static function (RestResourceInterface $restResource) use ($className): bool {
return $className !== null && $restResource instanceof $className;
return $restResource instanceof $className;
};
}
@@ -56,14 +56,14 @@ public function error(string $className): void
}
/**
* @param string|null $className
* @param string $className
*
* @return Closure
*/
public function filter(?string $className): Closure
public function filter(string $className): Closure
{
return static function (ControllerInterface $restController) use ($className): bool {
return $className !== null && $restController instanceof $className;
return $restController instanceof $className;
};
}
}

0 comments on commit d810d2e

Please sign in to comment.
You can’t perform that action at this time.