Completed
Pull Request — master (#16)
by
unknown
03:07
created

UserWithPasswordDataTransferObject   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 57
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 2
c 2
b 0
f 0
lcom 1
cbo 2
dl 0
loc 57
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A fromUser() 0 10 1
A getEntity() 0 10 1
1
<?php
2
3
namespace SumoCoders\FrameworkMultiUserBundle\DataTransferObject;
4
5
use SumoCoders\FrameworkMultiUserBundle\User\User;
6
use SumoCoders\FrameworkMultiUserBundle\User\UserWithPassword;
7
8
class UserWithPasswordDataTransferObject implements UserDataTransferObject
9
{
10
    /**
11
     * @var int
12
     */
13
    public $id;
14
15
    /**
16
     * @var string
17
     */
18
    public $userName;
19
20
    /**
21
     * @var string
22
     */
23
    public $displayName;
24
25
    /**
26
     * @var string
27
     */
28
    public $email;
29
30
    /**
31
     * @var string
32
     */
33
    public $plainPassword;
34
35
    /**
36
     * @param User $user
37
     *
38
     * @return User
39
     */
40
    public static function fromUser(User $user)
41
    {
42
        $baseUserTransferObject = new self();
43
        $baseUserTransferObject->id = $user->getId();
44
        $baseUserTransferObject->userName = $user->getUsername();
45
        $baseUserTransferObject->displayName = $user->getDisplayName();
46
        $baseUserTransferObject->email = $user->getEmail();
47
48
        return $baseUserTransferObject;
49
    }
50
51
    /**
52
     * @return UserWithPassword
53
     */
54
    public function getEntity()
55
    {
56
        return new UserWithPassword(
57
            $this->userName,
58
            $this->plainPassword,
59
            $this->displayName,
60
            $this->email,
61
            $this->id
62
        );
63
    }
64
}
65