/** * Use the `ValueType::NUMERIC_AS_STRING` flag to allow numeric values as strings * * @param string $value * @param int $flag A flag used by the `ValueType::getType()` method * @throws \ReflectionException if the parameter is not a string */ public function __construct($value, $flag = ValueType::MODE_STRICT) { if (!ValueType::isString($value) && !is_numeric($value)) { throw new \ReflectionException(sprintf(__METHOD__ . ' expects parameter one to be string, %s given', gettype($value))); } $this->setReadOnlyProperties($this::$_read_only); $this->type = ValueType::TYPE_STRING; $this->value = (string) $value; $this->length = strlen($value); }