Completed
Push — master ( 58620c...f23d9f )
by Vitaliy
02:20
created

DeviceToken   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 44
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 0
dl 0
loc 44
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 2
A getValue() 0 4 1
A __toString() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the AppleApnPush package
5
 *
6
 * (c) Vitaliy Zhuk <[email protected]>
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 Apple\ApnPush\Model;
13
14
/**
15
 * Device token model
16
 */
17
class DeviceToken
18
{
19
    /**
20
     * @var string
21
     */
22
    private $value;
23
24
    /**
25
     * Constructor.
26
     *
27
     * @param string $token
28
     *
29
     * @throws \InvalidArgumentException
30
     */
31
    public function __construct($token)
32
    {
33
        if (!preg_match('/^[0-9a-fA-F]{64}$/', $token)) {
34
            throw new \InvalidArgumentException(sprintf(
35
                'Invalid device token "%s".',
36
                $token
37
            ));
38
        }
39
40
        $this->value = $token;
41
    }
42
43
    /**
44
     * Get token value
45
     *
46
     * @return string
47
     */
48
    public function getValue()
49
    {
50
        return $this->value;
51
    }
52
53
    /**
54
     * {@inheritdoc}
55
     */
56
    public function __toString()
57
    {
58
        return $this->value;
59
    }
60
}
61