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

BeforeAddRelationEvent::hasRelation()   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\Content;
6
7
use eZ\Publish\API\Repository\Values\Content\ContentInfo;
8
use eZ\Publish\API\Repository\Values\Content\Relation;
9
use eZ\Publish\API\Repository\Values\Content\VersionInfo;
10
use eZ\Publish\Core\Event\BeforeEvent;
11
12
final class BeforeAddRelationEvent extends BeforeEvent
13
{
14
	public const NAME = 'ezplatform.event.relation.add.before';
15
16
	/**
17
     * @var \eZ\Publish\API\Repository\Values\Content\VersionInfo
18
     */
19
	private $sourceVersion;
20
21
	/**
22
     * @var \eZ\Publish\API\Repository\Values\Content\ContentInfo
23
     */
24
	private $destinationContent;
25
26
	/**
27
     * @var \eZ\Publish\API\Repository\Values\Content\Relation|null
28
     */
29
	private $relation;
30
31
32
	public function __construct(VersionInfo $sourceVersion, ContentInfo $destinationContent)
33
	{
34
		$this->sourceVersion = $sourceVersion;
35
		$this->destinationContent = $destinationContent;
36
	}
37
38
39
	public function getSourceVersion(): VersionInfo
40
	{
41
		return $this->sourceVersion;
42
	}
43
44
45
	public function getDestinationContent(): ContentInfo
46
	{
47
		return $this->destinationContent;
48
	}
49
50
51
	function getRelation(): ?Relation
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...
52
	{
53
		return $this->relation;
54
	}
55
56
57
	function setRelation(?Relation $relation): 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...
58
	{
59
		$this->relation = $relation;
60
	}
61
62
63
	function hasRelation(): 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...
64
	{
65
		return $this->relation instanceof Relation;
66
	}
67
}
68