CreateEvent::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
3
/*
4
 * This file is part of Sulu.
5
 *
6
 * (c) MASSIVE ART WebServices GmbH
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace Sulu\Component\DocumentManager\Event;
13
14
class CreateEvent extends AbstractEvent
15
{
16
    /**
17
     * @var object
18
     */
19
    private $document;
20
21
    /**
22
     * @var string
23
     */
24
    private $alias;
25
26
    /**
27
     * @param string $alias
28
     */
29
    public function __construct($alias)
30
    {
31
        $this->alias = $alias;
32
    }
33
34
    /**
35
     * @return object
36
     *
37
     * @throws \RuntimeException
38
     */
39
    public function getDocument()
40
    {
41
        if (!$this->document) {
42
            throw new \RuntimeException(
43
                'No document has been set, an event listener should have created a document before ' .
44
                'this method was called.'
45
            );
46
        }
47
48
        return $this->document;
49
    }
50
51
    /**
52
     * @param object $document
53
     */
54
    public function setDocument($document)
55
    {
56
        $this->document = $document;
57
    }
58
59
    /**
60
     * @return string
61
     */
62
    public function getAlias()
63
    {
64
        return $this->alias;
65
    }
66
}
67