Create a new message target with the given type and value.

@param string $type
@param string $value

@throws InvalidArgumentException

@return MessageTarget
971541
public static function with(string $type, string $value): self
    {
        $targetType = strtolower($type);

        $new = new self();
        $new->type = $targetType;

        switch ($targetType) {
            case self::CONDITION:
                $new->value = (string) Condition::fromValue($value);
                break;
            case self::TOKEN:
                $new->value = (string) RegistrationToken::fromValue($value);
                break;
            case self::TOPIC:
                $new->value = (string) Topic::fromValue($value);
                break;
            default:
                throw new InvalidArgumentException('Invalid target type "'.$type.'", valid type: "'.implode(', ', self::TYPES));
        }

        return $new;
    }
691045
protected function convertTypeToMask($value, $type)
    {
        if ($this->forceCaseInsensitivity) {
            $value = $this->encoding ? mb_strtolower($value, $this->encoding) : mb_strtolower($value);
        }

        switch ($type) {
            case FilterOperands::STRING_STARTS:
                $value .= '%';
                break;

            case FilterOperands::STRING_ENDS:
                $value = '%' . $value;
                break;

            case FilterOperands::STRING_CONTAINS:
                $value = '%' . $value . '%';
                break;

            case FilterOperands::STRING_EQUALS:
                break;

            default:
                throw new \InvalidArgumentException('Wrong type constant in string like expression mapper');
        }

        return $value;
    }
1256166
public function quote($value, $type)
    {
        $this->connect();

        return $this->_connection->quote($value, $type);
    }
96259
public function setType($type)
    {
        if (!self::isValidType($type)) {
            throw new \InvalidArgumentException("$type is not a valid event type");
        }

        $this->type = $type;

        return $this;
    }
1111855
public static function addHeader($type, $value, $code = null) {

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

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

		if(null !== $code && false === ('-' . intval($code) == '-' . $code)) {
			return trigger_error(sprintf('Argument 3 passed to %s() must be of the type integer, "%s" given', __METHOD__, gettype($code)), E_USER_ERROR);
		}

		if(null === $code) {
			return header($type . ':' . $value, true);
		}

		header($type . ':' . $value, true, $code);
	}
1163637
public function bind($parameter, $value, $type = null)
    {
        $this->statement->bindParam($parameter, $value, $this->driver->getPdoType($type, $value));
        return $this;
    }
710650
public function setValue($value)
    {
        if (is_string($value) === true) {
            $this->value = $value;
        } else {
            $msg = "The 'value' argument must be a string, '" . gettype($value) . "' given.";
            throw new InvalidArgumentException($msg);
        }
    }
464908
public static function create($value, $expectedType, $message = null)
    {
        if ($message === null) {
            $errorMessage = sprintf('Expected %s, got %s', $expectedType, self::getStringRepresentation($value));
        } elseif ($message === '') {
            $errorMessage = sprintf('Expected %s', $expectedType);
        } else {
            $errorMessage = sprintf('Expected %s. %s', $expectedType, $message);
        }
        return $errorMessage;
    }
862913
protected function findMail($type, $value)
    {
        $criterias = array($type => $value);

        $message = $this->getMailCatcherClient()->searchOne($criterias);

        if (null === $message) {
            throw new \InvalidArgumentException(sprintf('Unable to find a message with criterias "%s".', json_encode($criterias)));
        }

        return $message;
    }
718895
private function setThrottle($type, $key, $value)
    {
        if (!isset($this->throttles[$type][$key])) {
            throw new \InvalidArgumentException("Invalid throttle type or parameter given.");
        }

        $this->throttles[$type][$key] = $value;

        return $this;
    }
683325
public function setParameter($parameter, $value, $type = null)
    {
        $this->parameters[$parameter] = $value;

        if ($type !== null) {
            $this->parameterTypes[$parameter] = $type;
        }

        if (is_int($parameter)) {
            $this->mode = self::MODE_POSITIONAL;
            $this->parameterCounters['positional']++;
        } else {
            $this->mode = self::MODE_NAMED;
        }

        return $this;
    }
619415
protected function checkValueStructure( CoreValue $value )
    {
        if ( !is_array( $value->metas ) )
        {
            throw new InvalidArgumentType(
                '$value->metas',
                'array',
                $value->metas
            );
        }

        foreach ( $value->metas as $index => $meta )
        {
            if ( !$meta instanceof Meta )
            {
                throw new InvalidArgumentType(
                    '$value->metas[' . $index . ']',
                    "\\Novactive\\Bundle\\SEOBundle\\API\\Repository\\Values\\Metas\\Meta",
                    $meta
                );
            }
        }
    }
1015067
public function add($value)
    {
        if (!$value instanceof Contact) {
            throw new InvalidArgumentException(
                sprintf(
                    '%s only accepts instances of %s.',
                    __FUNCTION__, Contact::class
                )
            );
        }

        return parent::add($value);
    }
950441
public function setType($type)
    {
        if (!in_array($type, self::TYPES)) {
            throw new \InvalidArgumentException("bad type {$type}");
        }
        $this->type = $type;

        return $this;
    }
856146
public function setValue($value = null, $type = self::T_TEXT)
    {
        unset($this->rawValue);
        unset($this->value);
        $this->_initValue($value, $type);
    }
1138218
protected function checkValueStructure(BaseValue $value)
    {
        if (!is_int($value->destinationContentId) && !is_string($value->destinationContentId)) {
            throw new InvalidArgumentType(
                '$value->destinationContentId',
                'string|int',
                $value->destinationContentId
            );
        }
    }
423761
protected function setValue($value)
    {
        if (is_string($value)) {
            $this->value = $value;
        } else {
            throw new \InvalidArgumentException(
                "Invalid type '" . gettype($value). "' for argument 'value' given."
            );
        }

        return $this;
    }