Completed
Push — ezp-30616 ( ab7e14...128c78 )
by
unknown
17:09
created

BeforeCreateUserEvent::getUser()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace eZ\Publish\Core\Event\User;
6
7
use eZ\Publish\API\Repository\Values\User\User;
8
use eZ\Publish\API\Repository\Values\User\UserCreateStruct;
9
use eZ\Publish\Core\Event\BeforeEvent;
10
11
final class BeforeCreateUserEvent extends BeforeEvent
12
{
13
	public const NAME = 'ezplatform.event.user.create.before';
14
15
	/**
16
     * @var \eZ\Publish\API\Repository\Values\User\UserCreateStruct
17
     */
18
	private $userCreateStruct;
19
20
	/**
21
     * @var array
22
     */
23
	private $parentGroups;
24
25
	/**
26
     * @var \eZ\Publish\API\Repository\Values\User\User|null
27
     */
28
	private $user;
29
30
31
	public function __construct(UserCreateStruct $userCreateStruct, array $parentGroups)
32
	{
33
		$this->userCreateStruct = $userCreateStruct;
34
		$this->parentGroups = $parentGroups;
35
	}
36
37
38
	public function getUserCreateStruct(): UserCreateStruct
39
	{
40
		return $this->userCreateStruct;
41
	}
42
43
44
	public function getParentGroups(): array
45
	{
46
		return $this->parentGroups;
47
	}
48
49
50
	function getUser(): ?User
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
51
	{
52
		return $this->user;
53
	}
54
55
56
	function setUser(?User $user): void
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
57
	{
58
		$this->user = $user;
59
	}
60
61
62
	function hasUser(): bool
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
63
	{
64
		return $this->user instanceof User;
65
	}
66
}
67