/** * @return $this * @throws \RuntimeException */ public function initialize() { if ($this->getInitializer() !== null && !$this->isInitialized) { $this->isInitialized = true; $unknownType = new UnknownType(call_user_func($this->getInitializer())); if (!$unknownType->isCollection()) { throw new \RuntimeException(sprintf('Unexpected type given: %s', gettype($unknownType->getValue()))); } foreach ($unknownType->getAsCollection() as $element) { $this->getCollection()->add($element); } } return $this; }
public function testTestIfObjectIsCollectionReturnsTrueOnSuccess() { $u = new UnknownType(new Collection()); $this->assertTrue($u->isCollection()); }