FindEvent::getDebugMessage()   A
last analyzed

Complexity

Conditions 3
Paths 1

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 9
rs 9.6667
cc 3
eloc 6
nc 1
nop 0
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
use Sulu\Component\DocumentManager\Exception\DocumentManagerException;
15
16
class FindEvent extends AbstractEvent
17
{
18
    use EventOptionsTrait;
19
20
    /**
21
     * @var string
22
     */
23
    private $identifier;
24
25
    /**
26
     * @var string
27
     */
28
    private $locale;
29
30
    /**
31
     * @var object
32
     */
33
    private $document;
34
35
    /**
36
     * @param string $identifier
37
     * @param string $locale
38
     * @param array $options
39
     */
40
    public function __construct($identifier, $locale, array $options = [])
41
    {
42
        $this->identifier = $identifier;
43
        $this->locale = $locale;
44
        $this->options = $options;
0 ignored issues
show
Documentation Bug introduced by
It seems like $options of type array is incompatible with the declared type object<Symfony\Component...solver\OptionsResolver> of property $options.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
45
    }
46
47
    /**
48
     * {@inheritdoc}
49
     */
50
    public function getDebugMessage()
51
    {
52
        return sprintf(
53
            'i:%s d:%s l:%s',
54
            $this->identifier,
55
            $this->document ? spl_object_hash($this->document) : '<no document>',
56
            $this->locale ?: '<no locale>'
57
        );
58
    }
59
60
    /**
61
     * @return string
62
     */
63
    public function getId()
64
    {
65
        return $this->identifier;
66
    }
67
68
    /**
69
     * @return string
70
     */
71
    public function getLocale()
72
    {
73
        return $this->locale;
74
    }
75
76
    /**
77
     * @return object
78
     *
79
     * @throws DocumentManagerException
80
     */
81
    public function getDocument()
82
    {
83
        if (!$this->document) {
84
            throw new DocumentManagerException(sprintf(
85
                'No document has been set for the findEvent for "%s". An event listener should have done this.',
86
                $this->identifier
87
            ));
88
        }
89
90
        return $this->document;
91
    }
92
93
    /**
94
     * @param object $document
95
     */
96
    public function setDocument($document)
97
    {
98
        $this->document = $document;
99
    }
100
}
101