| 1 | <?php |
||
| 22 | class MulticastTarget implements TargetInterface, TokenTargetInterface |
||
| 23 | { |
||
| 24 | /** @var string[] */ |
||
| 25 | private array $registrationTokens = []; |
||
|
|
|||
| 26 | |||
| 27 | /** |
||
| 28 | * @param string $registrationToken |
||
| 29 | * |
||
| 30 | * @return $this |
||
| 31 | */ |
||
| 32 | public function addRegistrationToken(string $registrationToken): self |
||
| 33 | { |
||
| 34 | if (!\in_array($registrationToken, $this->registrationTokens)) { |
||
| 35 | $this->registrationTokens[] = $registrationToken; |
||
| 36 | } |
||
| 37 | |||
| 38 | return $this; |
||
| 39 | } |
||
| 40 | |||
| 41 | /** |
||
| 42 | * @param string[] $registrationTokens |
||
| 43 | * |
||
| 44 | * @return $this |
||
| 45 | */ |
||
| 46 | public function setRegistrationTokens(array $registrationTokens): self |
||
| 47 | { |
||
| 48 | foreach ($registrationTokens as $registrationToken) { |
||
| 49 | $this->addRegistrationToken($registrationToken); |
||
| 50 | } |
||
| 51 | |||
| 52 | return $this; |
||
| 53 | } |
||
| 54 | |||
| 55 | /** |
||
| 56 | * @return string[] |
||
| 57 | */ |
||
| 58 | public function getRegistrationTokens(): array |
||
| 59 | { |
||
| 60 | return $this->registrationTokens; |
||
| 61 | } |
||
| 62 | |||
| 63 | /** |
||
| 64 | * {@inheritdoc} |
||
| 65 | */ |
||
| 66 | public function getSequentialSentTokens(): array |
||
| 67 | { |
||
| 68 | return $this->getRegistrationTokens(); |
||
| 69 | } |
||
| 70 | |||
| 71 | /** |
||
| 72 | * {@inheritdoc} |
||
| 73 | */ |
||
| 74 | public function getNumberOfSequentialSentTokens(): int |
||
| 75 | { |
||
| 76 | return \count($this->getRegistrationTokens()); |
||
| 77 | } |
||
| 78 | } |
||
| 79 |