Completed
Push — master ( 2c087d...9abca0 )
by Rémi
05:41
created

CreateUserCommand   A

Complexity

Total Complexity 7

Size/Duplication

Total Lines 99
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 6
Bugs 0 Features 1
Metric Value
wmc 7
c 6
b 0
f 1
lcom 1
cbo 0
dl 0
loc 99
ccs 16
cts 16
cp 1
rs 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A getId() 0 4 1
A getCommandName() 0 4 1
A getOriginalUser() 0 4 1
A getPreferredLanguage() 0 4 1
A getContext() 0 4 1
A create() 0 11 1
1
<?php
2
3
namespace MessageApp\Command;
4
5
use League\Tactician\Plugins\NamedCommand\NamedCommand;
6
use MessageApp\User\ApplicationUserId;
7
use RemiSan\Context\Context;
8
use RemiSan\Context\ContextAware;
9
10
class CreateUserCommand implements NamedCommand, ContextAware
11
{
12
    const NAME = 'USER.CREATE';
13
14
    /**
15
     * @var ApplicationUserId
16
     */
17
    private $id;
18
19
    /**
20
     * @var object
21
     */
22
    private $originalUser;
23
24
    /**
25
     * @var string
26
     */
27
    private $preferredLanguage;
28
29
    /**
30
     * @var Context
31 3
     */
32
    private $context;
33 3
34
    /**
35
     * Constructor.
36
     */
37
    public function __construct()
38
    {
39
    }
40 3
41
    /**
42 3
     * @return ApplicationUserId
43
     */
44
    public function getId()
45
    {
46
        return $this->id;
47
    }
48
49
    /**
50 3
     * Returns the command name
51
     *
52 3
     * @return string
53
     */
54
    public function getCommandName()
55
    {
56
        return self::NAME;
57
    }
58 3
59
    /**
60 3
     * Returns the user
61
     *
62
     * @return object
63
     */
64
    public function getOriginalUser()
65
    {
66
        return $this->originalUser;
67
    }
68 3
69
    /**
70 3
     * @return string
71
     */
72
    public function getPreferredLanguage()
73
    {
74
        return $this->preferredLanguage;
75
    }
76
77
    /**
78
     * Returns the context
79
     *
80
     * @return Context
81
     */
82 3
    public function getContext()
83
    {
84 3
        return $this->context;
85
    }
86 3
87 3
    /**
88 3
     * Static constructor.
89
     *
90 3
     * @param ApplicationUserId $id
91
     * @param object            $originalUser
92
     * @param string            $preferredLanguage
93
     * @param Context           $context
94
     *
95
     * @return CreateUserCommand
96
     */
97
    public static function create(ApplicationUserId $id, $originalUser, $preferredLanguage, Context $context = null)
98
    {
99
        $obj = new self();
100
101
        $obj->id = $id;
102
        $obj->originalUser = $originalUser;
103
        $obj->preferredLanguage = $preferredLanguage;
104
        $obj->context = $context;
105
106
        return $obj;
107
    }
108
}
109