diff --git a/composer.json b/composer.json index a9804a3..e269f0f 100644 --- a/composer.json +++ b/composer.json @@ -18,7 +18,7 @@ "email": "vincent@girol.fr" } ], - "minimum-stability": "dev", + "minimum-stability": "stable", "autoload": { "psr-4": { "VGirol\\JsonApiAssert\\": "src/" diff --git a/src/Factory/CollectionFactory.php b/src/Factory/CollectionFactory.php index cd79121..54f76b2 100644 --- a/src/Factory/CollectionFactory.php +++ b/src/Factory/CollectionFactory.php @@ -15,7 +15,7 @@ class CollectionFactory extends BaseFactory /** * Undocumented function * - * @param array|array $collection + * @param array|array $collection * @return static */ public function setCollection($collection) @@ -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 diff --git a/src/Factory/HelperFactory.php b/src/Factory/HelperFactory.php index 59f6583..4441dc3 100644 --- a/src/Factory/HelperFactory.php +++ b/src/Factory/HelperFactory.php @@ -6,6 +6,11 @@ class HelperFactory { public static function getAliases(): array + { + return []; + } + + private static function getDefaultAliases(): array { return [ 'collection' => CollectionFactory::class, @@ -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)