public function testCreateNewUnknownWithStringValue() { $u = new UnknownType('string value'); $this->assertTrue($u->isString()); $this->assertTrue($u->isScalar()); $this->assertFalse($u->isNull()); $this->assertEquals('string value', $u->getAsString()); $this->assertEquals('string value', $u->getValue()); }
/** * @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; }