Assert that the given value for the given channel name is valid

@param integer $value
@param string  $channel

@return \Jaguar\Color\RGBColor
@throws \InvalidArgumentException
506512
protected function assertChannelValue($value, $channel)
    {
        if (!$this->isValidChannelValue($value, $channel)) {
            throw new \InvalidArgumentException(
            sprintf('Invalid Value "%s" For The %s Channel'
                    , $value, ucfirst($value))
            );
        }

        return $this;
    }
7513
public static function mustBeNullableInt($value)
    {
        if (is_int($value) === false && $value != null) {
            throw new MWrongTypeException('\$value', 'int|null', gettype($value));
        }
    }
620328
public function setValue($value)
    {
        if (!is_string($value) || (is_object($value) && !method_exists($value, "__toString"))) {
            throw new InvalidArgumentException(sprintf(
                "Invalid argument given to %s, expected a string, %s given",
                __METHOD__,
                is_object($value) ? get_class($value) : gettype($value)
            ));
        }

        $value = (string) $value;

        if (null !== $regex = $this->getValidationRegex()) {
            if (! preg_match($regex, $value)) {
                throw new InvalidArgumentException(sprintf(
                    "The given value '%s' doesn't match the validation regular expression: %s",
                    $value,
                    $regex
                ));
            }
        }

        $this->value = $value;

        return $this;
    }
316877
public function setIdentifier($value)
    {
        if ($value !== null && ($value < 0 || $value > 0xFFFF)) {
            throw new \InvalidArgumentException(
                sprintf(
                    'Expected an identifier between 0x0000 and 0xFFFF but got %x',
                    $value
                )
            );
        }

        $this->identifier = $value;
    }
817936
public static function isString($value) {
        if(is_scalar($value)) {
            return (string)$value;
        } elseif(is_object($value) && method_exists($value, '__toString')) {
            return $value->__toString();
        } else {
            throw new \InvalidArgumentException('Must be String: ' . print_r($value, true));
        }
    }
1265597
public static function isOn($value, $flag)
    {
        if (!Int::is($value)) {
            throw new \InvalidArgumentException("The \$value parameter must be of type int.");
        }

        if (!static::is($flag)) {
            throw new \InvalidArgumentException("The \$flag parameter must be of type int and a power of 2.");
        }

        return static::is($value & $flag);
    }
890311
public function validate($value) {
        if(filter_var($value, FILTER_VALIDATE_INT)===false) {
            return new ValidationResult(false, 'Not a valid integer');
        }        
        return new ValidationResult(true);
    }
882876
public static function fromValue($value)
    {
        $values = static::getValues();
        if (array_key_exists($value, $values)) {
            return new static($values[$value], $value);
        }
        throw new \InvalidArgumentException("No enum constant value '$value' class " . get_called_class());
    }
1126534
public function setGreen($value)
    {
        $this->assertChannelValue($value, self::CHANNEL_GREEN);
        $this->green = $value;

        return $this;
    }
88742
public function isAssignableFromValue($value)
    {
        switch ($this->name)
        {
            case self::INTEGER_NAME:
                return is_int($value);
            case self::FLOAT_NAME:
                return is_float($value);
            case self::STRING_NAME:
                return is_string($value);
            case self::BOOLEAN_NAME:
                return is_bool($value);
            case self::MIXED_NAME:
                return true;
            case self::RESOURCE_NAME:
                return is_resource($value);
            case self::OBJECT_NAME:
                return is_object($value);
            case self::NULL_NAME:
                return is_null($value);
            case self::CALLABLE_NAME:
                return is_callable($value);
            default:
                throw new Exception("Implementation error");
        }
    }
1362174
public function checkValue(&$value)
    {
        if (is_string($value)) {
            $value = Placeholder::replaceStringsAndComments($value);
            $value = Placeholder::removeCommentPlaceholders($value, true);
            $value = Placeholder::replaceStringPlaceholders($value, true);
            $value = trim($value);

            if ($value !== '') {
                return true;
            } else {
                $this->setIsValid(false);
            }
        } else {
            throw new \InvalidArgumentException(
                "Invalid type '" . gettype($value). "' for argument 'value' given."
            );
        }
    }
681884
protected function checkValueStructure(BaseValue $value)
    {
        if (isset($value->inputUri) && !is_string($value->inputUri)) {
            throw new InvalidArgumentType('$value->inputUri', 'string', $value->inputUri);
        }

        if (isset($value->id) && !is_string($value->id)) {
            throw new InvalidArgumentType('$value->id', 'string', $value->id);
        }

        // Required parameter $fileName
        if (!isset($value->fileName) || !is_string($value->fileName)) {
            throw new InvalidArgumentType('$value->fileName', 'string', $value->fileName);
        }

        // Optional parameter $alternativeText
        if (isset($value->alternativeText) && !is_string($value->alternativeText)) {
            throw new InvalidArgumentType(
                '$value->alternativeText',
                'string',
                $value->alternativeText
            );
        }

        if (isset($value->fileSize) && (!is_int($value->fileSize) || $value->fileSize < 0)) {
            throw new InvalidArgumentType(
                '$value->fileSize',
                'int',
                $value->alternativeText
            );
        }
    }
745710
public function setValue($value)
	{
		if ( ! is_string($value) && ! is_int($value))
		{
			throw new \InvalidArgumentException('A RadioGroup value must be a string or int');
		}

		$this->value = $value;

		// Work out which of our children need to be selected
		foreach ($this->getContents() as $item)
		{
			if ($item->getValue() == $value)
			{
				$item->setChecked(true);
			}
			else
			{
				$item->setChecked(false);
			}
		}

		return $this;
	}
821273
public function setColour($colour)
    {
        if (!preg_match('/^[a-f0-9]{6}$/i', $colour)) {
            throw new \InvalidArgumentException(sprintf('Value %s must be a valid hex colour', $colour));
        }

        $this->colour = $colour;

        return $this;
    }
103205
protected function verifyElement($value)
    {
        if (!$this->elementType->isOfType($value)) {
            throw Exception\InvalidArgumentException::format(
                'Invalid element supplied to collection: expecting type of %s, %s given',
                $this->elementType->asTypeString(), Debug::getType($value)
            );
        }
    }
931253
public function isValid($value)
    {
        if (!is_string($value) && !is_int($value)) {
            $this->_error(self::INVALID);
            return false;
        }

        $this->_setValue($value);
        if (!ctype_xdigit((string) $value)) {
            $this->_error(self::NOT_HEX);
            return false;
        }

        return true;
    }
840064
public function validate($value) {
        if(!filter_var($value, FILTER_VALIDATE_IP, $this->flags)) {
            return new ValidationResult(false, 'Not a valid ip address');
        }        
        return new ValidationResult(true);
    }