Completed
Push — master ( 08753a...42665f )
by Sascha-Oliver
05:38
created

User::getId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 4
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 4
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This software may be modified and distributed under the terms
7
 * of the MIT license.  See the LICENSE file for details.
8
 */
9
10
namespace FAPI\PhraseApp\Model\Translation;
11
12
use FAPI\PhraseApp\Model\CreatableFromArray;
13
14
/**
15
 * @author Sascha-Oliver Prolic <[email protected]>
16
 */
17 View Code Duplication
class User implements CreatableFromArray
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...
18
{
19
    /**
20
     * @var string
21
     */
22
    private $id;
23
24
    /**
25
     * @var string
26
     */
27
    private $username;
28
29
    /**
30
     * @var string
31
     */
32
    private $name;
33
34
    /**
35
     * @param array $data
36
     *
37
     * @return User
38
     */
39
    public static function createFromArray(array $data)
40
    {
41
        $self = new self();
42
43
        if (isset($data['id'])) {
44
            $self->setId($data['id']);
45
        }
46
        if (isset($data['username'])) {
47
            $self->setUsername($data['username']);
48
        }
49
        if (isset($data['name'])) {
50
            $self->setName($data['name']);
51
        }
52
53
        return $self;
54
    }
55
56
    public function getId(): string
57
    {
58
        return $this->id;
59
    }
60
61
    private function setId(string $id)
62
    {
63
        $this->id = $id;
64
    }
65
66
    public function getUsername(): string
67
    {
68
        return $this->username;
69
    }
70
71
    private function setUsername(string $username)
72
    {
73
        $this->username = $username;
74
    }
75
76
    public function getName(): string
77
    {
78
        return $this->name;
79
    }
80
81
    private function setName(string $name)
82
    {
83
        $this->name = $name;
84
    }
85
}
86