messageType example

if (isset($options['message_type'])) {
            self::validateMessageType($options['message_type']);
        }

        $this->options = $options;
    }

    public static function fromNotification(Notification $notification): self
    {
        $options = new self();
        match ($notification->getImportance()) {
            Notification::IMPORTANCE_HIGH, Notification::IMPORTANCE_URGENT => $options->messageType(self::MESSAGE_TYPE_QUALITY_HIGH),
            Notification::IMPORTANCE_MEDIUM => $options->messageType(self::MESSAGE_TYPE_QUALITY_MEDIUM),
            Notification::IMPORTANCE_LOW => $options->messageType(self::MESSAGE_TYPE_QUALITY_LOW),
            default => $options->messageType(self::MESSAGE_TYPE_QUALITY_HIGH),
        };

        return $options;
    }

    public function toArray(): array
    {
        return $this->options;
    }
$options = MobytOptions::fromNotification($notification)->toArray();

        $this->assertSame(MobytOptions::MESSAGE_TYPE_QUALITY_HIGH, $options['message_type']);
    }

    /** * @dataProvider validMessageTypes */
    public function testMessageType(string $type)
    {
        $mobytOptions = new MobytOptions();
        $mobytOptions->messageType($type);

        $this->assertSame(['message_type' => $type]$mobytOptions->toArray());
    }

    public static function validMessageTypes(): iterable
    {
        yield [MobytOptions::MESSAGE_TYPE_QUALITY_HIGH];
        yield [MobytOptions::MESSAGE_TYPE_QUALITY_MEDIUM];
        yield [MobytOptions::MESSAGE_TYPE_QUALITY_LOW];
    }

    
Home | Imprint | This part of the site doesn't use cookies.