/** * Init's a new instance. * * @param mixed $value The base value. * @throws \Beluga\BelugaError If $value is of type {@see Type} */ public function __construct($value) { $this->value = $value; $this->isStringConvertible = TypeTool::IsStringConvertible($value, $this->stringValue); if (!$this->isStringConvertible) { $this->stringValue = null; } if (\is_null($value)) { $this->typeName = Type::PHP_NULL; } else { if (\is_string($value)) { $this->typeName = Type::PHP_STRING; } else { if (\is_array($value)) { $this->typeName = Type::PHP_ARRAY; } else { if (\is_object($value)) { if ($value instanceof Type) { throw new BelugaError('Core', 'Could not create \\Beluga\\Type-Instance of a \\Beluga\\Type-Value!'); } $this->typeName = \get_class($value); } else { if (\is_int($value)) { $this->typeName = Type::PHP_INTEGER; } else { if (\is_double($value)) { $this->typeName = Type::PHP_DOUBLE; } else { if (\is_float($value)) { $this->typeName = Type::PHP_FLOAT; } else { if (\is_bool($value)) { $this->typeName = Type::PHP_BOOLEAN; } else { if (\is_resource($value)) { $this->typeName = Type::PHP_RESOURCE; } else { $this->typeName = Type::PHP_UNKNOWN; } } } } } } } } } }