DeviceToken::getValue()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 4
Ratio 100 %

Importance

Changes 0
Metric Value
dl 4
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types = 1);
4
5
/*
6
 * This file is part of the AppleApnPush package
7
 *
8
 * (c) Vitaliy Zhuk <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code
12
 */
13
14
namespace Apple\ApnPush\Model;
15
16
/**
17
 * Device token model
18
 */
19 View Code Duplication
class DeviceToken
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
20
{
21
    /**
22
     * @var string
23
     */
24
    private $value;
25
26
    /**
27
     * Constructor.
28
     *
29
     * @param string $token
30
     *
31
     * @throws \InvalidArgumentException
32
     */
33
    public function __construct(string $token)
34
    {
35
        if (!\preg_match('/^[0-9a-fA-F]{64}$/', $token)) {
36
            throw new \InvalidArgumentException(sprintf(
37
                'Invalid device token "%s".',
38
                $token
39
            ));
40
        }
41
42
        $this->value = $token;
43
    }
44
45
    /**
46
     * Get token value
47
     *
48
     * @return string
49
     */
50
    public function getValue(): string
51
    {
52
        return $this->value;
53
    }
54
55
    /**
56
     * {@inheritdoc}
57
     */
58
    public function __toString()
59
    {
60
        return $this->value;
61
    }
62
}
63