for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace Zenstruck\Foundry;
/**
* @author Kevin Bond <[email protected]>
*/
final class FactoryCollection
{
/** @var Factory */
private $factory;
/** @var int */
private $count;
public function __construct(Factory $factory, int $count)
if ($count < 1) {
throw new \InvalidArgumentException('Count must be greater than 0.');
}
$this->factory = $factory;
$this->count = $count;
* @param array|callable $attributes
*
* @return Proxy[]|object[]
public function create($attributes = []): array
return $this->factory->createMany($this->count, $attributes);
* @return Factory[]
public function all(): array
return \array_map(
function() {
return clone $this->factory;
},
\array_fill(0, $this->count, null)
);
public function factory(): Factory
return $this->factory;