@param string|int $value

@return static
@throws \UnexpectedValueException
506152
final public static function create($value)
    {
        $key = get_called_class() . $value;

        if (isset(self::$instances[$key])) {
            return self::$instances[$key];
        }

        $values = static::values();
        if (!in_array($value, $values)) {
            throw new \UnexpectedValueException("Value '$value' is not part of the enum " . get_called_class());
        }

        self::$instances[$key] = new static($value);
        return self::$instances[$key];
    }
1077635
protected function setValue($value)
    {
        if (!is_int($value)) {
            throw InvalidTypeException::fromMessageAndPrototype("Value must be an integer", static::prototype());
        }
        $this->value = $value;
    }
657410
protected function castValue($value)
    {
        switch ($value) {
            case 'false':
                return false;

            case 'true':
                return true;
        }

        if (is_numeric($value)) {
            $value = intval($value);
        }

        return $value;
    }
225760
public static function FromValue( $value )
	{
		if ( is_string( $value ) && ( ! is_numeric( $value ) || ( ! is_int( $value + 0 ) && is_double( $value + 0 ) ) ) )
		{
			throw XPath2Exception::withErrorCodeAndParams( "FORG0001", Resources::FORG0001, array( $value, "integer" ) );
		}

		if ( is_numeric( $value ) )
		{
			if ( is_infinite( $value ) )
				throw XPath2Exception::withErrorCodeAndParams( "FOAR0001", Resources::FOAR0001, array( $value, "integer" ) );

			if ( $value > PHP_INT_MAX || $value < PHP_INT_MIN )
				throw XPath2Exception::withErrorCodeAndParams( "FOAR0002", Resources::FOAR0002, array( $value, "integer" ) );
		}

		return new Integer( $value );
	}
361387
public function setValue($value)
	{
		// any preparation goes here, for example casting to int
		$errors = $this->getValidationErrors($value);
		// if specific validation existed would go here & if
		// anything goes wrong will put error message into errors
		if(!empty($errors))
			throw $this->getContext()->getModel('ValidationException', 'Form', array(($errors)));
		return $value;
	}
665329
public function transform($value)
    {
        if (null === $value) {
            return null;
        }

        if (!is_string($value)) {
            throw new UnexpectedTypeException($value, 'string');
        }

        return explode($this->separator, $value);
    }
112942
public function parse($value)
    {
        switch (true) {

            case is_string($value):
                $this->initFromString($value);
                break;

            case is_int($value):
                $this->initFromInteger($value);
                break;

            case is_array($value):
                $this->initFromArray($value);
                break;

            case is_object($value):
                $this->initFromObject($value);
                break;

            case is_null($value):
                $this->initFromArray([255, 255, 255, 0]);
                break;

            default:
                throw new \Intervention\Image\Exception\NotReadableException(
                    "Color format ({$value}) cannot be read."
                );
        }

        return $this;
    }
148868
public function setValue( $value ) {
		$this->value = $this->cleanUpValue( $value );
		$this->input->setValue( $this->value );
		return $this;
	}
485267
public static function getByValue($value)
    {
        $class = get_called_class();
        $constants = array_flip(static::getConstants());
        if (isset($constants[$value])) {
            return self::$instances[$class][$constants[$value]] = new $class($value);
        } else {
            throw new \InvalidArgumentException('"' . $value . '" not defined');
        }
    }
1080327
public static function integer($value){

		$value = static::_nullValue($value);

		if($value !== null){

			$value = (int) $value;
		}

		return $value;
	}
921708
public static function createByValue($value)
    {
        $constants = self::getConstantsByValue();

        if (!array_key_exists($value, $constants)) {
            throw EnumException::invalidValue(get_called_class(), $value);
        }

        return new static ($value);
    }
1303889
protected function getValidTimestamp($value)
    {
        if (gettype($value) == 'integer') {
            return $value;
        }

        if ($value instanceof DateTime) {
            return $value->getTimestamp();
        }

        throw new UnexpectedValueException('Instance of DateTime required for a valid timestamp');
    }
1164945
protected function setValue($value)
    {
        if (is_string($value)) {
            $value = trim($value);
            if ($value !== "") {
                $this->value = $value;
            } else {
                throw new \InvalidArgumentException("Invalid value for argument 'value' given.");
            }
        } else {
            throw new \InvalidArgumentException(
                "Invalid type '" . gettype($value) . "' for argument 'value' given. String expected."
            );
        }

        return $this;
    }
1322016
public function value($value = null) {

        if(null !== $value && false === is_string($value) && false === is_numeric($value)) {
            return trigger_error(sprintf('Argument 1 passed to %s() must be of the type string or number, "%s" given', __METHOD__, gettype($value)), E_USER_ERROR);
        }

        $this -> value = (string) $value;
        $this -> attributes['value'] = (string) $value;

        return $this;
    }
875316
final public function set($value)
    {
        $isValid = false;

        if ($value === null) {
            $this->clear();
            $isValid = true;
        } elseif (is_object($value)) {
            $isValid = $this->fromObject($value);
        } elseif (is_bool($value)) {
            $isValid = $this->fromBool($value);
        } elseif (is_int($value)) {
            $isValid = $this->fromInt($value);
        } elseif (is_double($value)) {
            $isValid = $this->fromDouble($value);
        } elseif (is_string($value)) {
            $isValid = $this->fromString($value);
        } elseif (is_array($value)) {
            $isValid = $this->fromArray($value);
        } elseif (is_resource($value)) {
            $isValid = $this->fromResource($value);
        }

        if (!$isValid) {
            throw new \UnexpectedValueException(sprintf(
                'The value of type "%s" could not be converted to "%s".', gettype($value), get_called_class()
            ));
        }
        return $this;
    }
461000
static function ensureValue($value)
    {
        if (!self::hasValue($value)) {
            throw new InvalidValueException(sprintf(
                'The value %s is not defined in enum class "%s", known values: %s',
                self::dumpValue($value),
                static::class,
                implode(', ', array_map([static::class, 'dumpValue'], self::getValues()))
            ));
        }
    }
975813
public function setSentCountPotential($value = null)
    {
        if ($value === null || $value === '' || $value === false) {
            $this->sentCountPotential = null;
        } else {
            $this->sentCountPotential = (int) $value;
        }

        return $this;
    }