Test Setup Failed
Push — master ( 01683c...feea73 )
by Vitaliy
03:11
created

ApnId   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 0
dl 38
loc 38
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 11 11 2
A getValue() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

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
 * UUID identifier for APN
18
 */
19 View Code Duplication
class ApnId
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 $value
30
     *
31
     * @throws \InvalidArgumentException
32
     */
33
    public function __construct(string $value)
34
    {
35
        if (!preg_match('/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/', $value)) {
36
            throw new \InvalidArgumentException(sprintf(
37
                'Invalid UUID identifier "%s".',
38
                $value
39
            ));
40
        }
41
42
        $this->value = $value;
43
    }
44
45
    /**
46
     * Get value
47
     *
48
     * @return string
49
     *
50
     * @throws \LogicException
51
     */
52
    public function getValue(): string
53
    {
54
        return (string) $this->value;
55
    }
56
}
57