Completed
Push — master ( 72cf95...b4fc03 )
by Artem
08:38
created

MulticastTarget::getNumberOfSequentialSentTokens()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/*
3
 * This file is part of the FirebaseCloudMessagingBundle
4
 *
5
 * (c) Artem Henvald <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
declare(strict_types=1);
12
13
namespace Fresh\FirebaseCloudMessagingBundle\Message\Part\Target;
14
15
/**
16
 * MulticastTarget.
17
 *
18
 * @see https://firebase.google.com/docs/cloud-messaging/http-server-ref#table1
19
 *
20
 * @author Artem Henvald <[email protected]>
21
 */
22
class MulticastTarget implements TargetInterface, TokenTargetInterface
23
{
24
    /** @var string[] */
25
    private $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