Completed
Push — master ( b93c78...0ed572 )
by Julián
02:22
created

ApnsRecipient::setToken()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 11
rs 9.4285
cc 3
eloc 6
nc 2
nop 1
1
<?php
2
/**
3
 * Push notification services abstraction (http://github.com/juliangut/tify)
4
 *
5
 * @link https://github.com/juliangut/tify for the canonical source repository
6
 *
7
 * @license https://github.com/juliangut/tify/blob/master/LICENSE
8
 */
9
10
namespace Jgut\Tify\Recipient;
11
12
class ApnsRecipient extends AbstractRecipient
13
{
14
    /**
15
     * {@inheritdoc}
16
     *
17
     * @throws \InvalidArgumentException
18
     */
19
    public function setToken($token)
20
    {
21
        $token = trim($token);
22
        if (!ctype_xdigit($token) || strlen($token) !== 64) {
23
            throw new \InvalidArgumentException('APNS token must be a 64 hex string');
24
        }
25
26
        $this->token = $token;
27
28
        return $this;
29
    }
30
}
31