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;
    }
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;
    }
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 ; }
Create a new message target with the given type and value.

@param string $type
@param string $value

@throws InvalidArgumentException

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