|
| 1 | +<?php |
| 2 | + |
| 3 | +/* |
| 4 | + * This file is part of the Symfony package. |
| 5 | + * |
| 6 | + * (c) Fabien Potencier <fabien@symfony.com> |
| 7 | + * |
| 8 | + * For the full copyright and license information, please view the LICENSE |
| 9 | + * file that was distributed with this source code. |
| 10 | + */ |
| 11 | + |
| 12 | +namespace Symfony\Component\Notifier\Bridge\GatewayApi; |
| 13 | + |
| 14 | +use Symfony\Component\Notifier\Message\MessageOptionsInterface; |
| 15 | + |
| 16 | +/** |
| 17 | + * @author gnito-org <https://github.com/gnito-org> |
| 18 | + */ |
| 19 | +final class GatewayApiOptions implements MessageOptionsInterface |
| 20 | +{ |
| 21 | + private array $options; |
| 22 | + |
| 23 | + public function __construct(array $options = []) |
| 24 | + { |
| 25 | + $this->options = $options; |
| 26 | + } |
| 27 | + |
| 28 | + public function getClass(): ?int |
| 29 | + { |
| 30 | + return $this->options['class'] ?? null; |
| 31 | + } |
| 32 | + |
| 33 | + public function getUserRef(): ?string |
| 34 | + { |
| 35 | + return $this->options['user_ref'] ?? null; |
| 36 | + } |
| 37 | + |
| 38 | + public function getCallbackUrl(): ?string |
| 39 | + { |
| 40 | + return $this->options['callback_url'] ?? null; |
| 41 | + } |
| 42 | + |
| 43 | + public function getFrom(): ?string |
| 44 | + { |
| 45 | + return $this->options['from'] ?? null; |
| 46 | + } |
| 47 | + |
| 48 | + public function getRecipientId(): ?string |
| 49 | + { |
| 50 | + return $this->options['recipient_id'] ?? null; |
| 51 | + } |
| 52 | + |
| 53 | + public function setClass(int $class): self |
| 54 | + { |
| 55 | + $this->options['class'] = $class; |
| 56 | + |
| 57 | + return $this; |
| 58 | + } |
| 59 | + |
| 60 | + public function setUserRef(string $userRef): self |
| 61 | + { |
| 62 | + $this->options['user_ref'] = $userRef; |
| 63 | + |
| 64 | + return $this; |
| 65 | + } |
| 66 | + |
| 67 | + public function setCallbackUrl(string $callbackUrl): self |
| 68 | + { |
| 69 | + $this->options['callback_url'] = $callbackUrl; |
| 70 | + |
| 71 | + return $this; |
| 72 | + } |
| 73 | + |
| 74 | + public function setFrom(string $from): self |
| 75 | + { |
| 76 | + $this->options['from'] = $from; |
| 77 | + |
| 78 | + return $this; |
| 79 | + } |
| 80 | + |
| 81 | + public function setRecipientId(string $id): self |
| 82 | + { |
| 83 | + $this->options['recipient_id'] = $id; |
| 84 | + |
| 85 | + return $this; |
| 86 | + } |
| 87 | + |
| 88 | + public function toArray(): array |
| 89 | + { |
| 90 | + $options = $this->options; |
| 91 | + if (isset($options['recipient_id'])) { |
| 92 | + unset($options['recipient_id']); |
| 93 | + } |
| 94 | + |
| 95 | + return $options; |
| 96 | + } |
| 97 | +} |
0 commit comments