Skip to content
This repository has been archived by the owner on Feb 4, 2022. It is now read-only.

Commit

Permalink
Updated HelperFactory
Browse files Browse the repository at this point in the history
  • Loading branch information
VGirol committed Jun 11, 2019
1 parent ada9c96 commit c6cec55
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"email": "[email protected]"
}
],
"minimum-stability": "dev",
"minimum-stability": "stable",
"autoload": {
"psr-4": {
"VGirol\\JsonApiAssert\\": "src/"
Expand Down
12 changes: 10 additions & 2 deletions src/Factory/CollectionFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class CollectionFactory extends BaseFactory
/**
* Undocumented function
*
* @param array<ResourceObjectFactory>|array<ResourceObjectFactory> $collection
* @param array<ResourceIdentifierFactory>|array<ResourceObjectFactory> $collection
* @return static
*/
public function setCollection($collection)
Expand All @@ -38,9 +38,17 @@ function ($resource) {
);
}

public function each($callback): void
/**
* Undocumented function
*
* @param callable $callback
* @return static
*/
public function each($callback)
{
array_walk($this->array, $callback);

return $this;
}

public function map($callback): array
Expand Down
7 changes: 6 additions & 1 deletion src/Factory/HelperFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@
class HelperFactory
{
public static function getAliases(): array
{
return [];
}

private static function getDefaultAliases(): array
{
return [
'collection' => CollectionFactory::class,
Expand All @@ -18,7 +23,7 @@ public static function getAliases(): array

public static function getClassName(string $key): string
{
$aliases = static::getAliases();
$aliases = array_merge(static::getDefaultAliases(), static::getAliases());
if (!isset($aliases[$key])) {
throw new \Exception(
sprintf('Inexistant key "%s".', $key)
Expand Down

0 comments on commit c6cec55

Please sign in to comment.