Message::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
/*
4
 * This file is part of the MilioooMessageBundle package.
5
 *
6
 * (c) Michiel boeckaert <[email protected]>
7
 * This source file is subject to the MIT license that is bundled
8
 * with this source code in the file LICENSE.
9
 */
10
11
namespace Miliooo\Messaging\Model;
12
13
use Miliooo\Messaging\User\ParticipantInterface;
14
use Miliooo\Messaging\Model\MessageMetaInterface;
15
use Doctrine\Common\Collections\ArrayCollection;
16
use Miliooo\Messaging\Model\ThreadInterface;
17
18
/**
19
 * The message model
20
 *
21
 * @author Michiel Boeckaert <[email protected]>
22
 */
23
abstract class Message implements MessageInterface
0 ignored issues
show
Coding Style introduced by
Message does not seem to conform to the naming convention (^Abstract|Factory$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
24
{
25
    /**
26
     * The unique id of the message
27
     *
28
     * @var integer The unique id of the message
29
     */
30
    protected $id;
31
32
    /**
33
     * The creation time of the message
34
     *
35
     * @var \DateTime
36
     */
37
    protected $createdAt;
38
39
    /**
40
     * The sender of the message
41
     *
42
     * @var ParticipantInterface
43
     */
44
    protected $sender;
45
46
    /**
47
     * The body of the message
48
     *
49
     * @var string
50
     */
51
    protected $body;
52
53
    /**
54
     * A collection of message metas
55
     *
56
     * @var ArrayCollection
57
     */
58
    protected $messageMeta;
59
60
    /**
61
     * The thread this message belongs to
62
     *
63
     * @var ThreadInterface
64
     */
65
    protected $thread;
66
67
    /**
68
     * Constructor.
69
     */
70
    public function __construct()
71
    {
72
        $this->messageMeta = new ArrayCollection();
73
    }
74
75
    /**
76
     * {@inheritdoc}
77
     */
78
    public function getId()
79
    {
80
        return $this->id;
81
    }
82
83
    /**
84
     * {@inheritdoc}
85
     */
86
    public function setCreatedAt(\DateTime $createdAt)
87
    {
88
        $this->createdAt = $createdAt;
89
    }
90
91
    /**
92
     * {@inheritdoc}
93
     */
94
    public function getCreatedAt()
95
    {
96
        return $this->createdAt;
97
    }
98
99
    /**
100
     * {@inheritdoc}
101
     */
102
    public function getBody()
103
    {
104
        return $this->body;
105
    }
106
107
    /**
108
     * {@inheritdoc}
109
     */
110
    public function setBody($body)
111
    {
112
        $this->body = $body;
113
    }
114
115
    /**
116
     * {@inheritdoc}
117
     */
118
    public function setSender(ParticipantInterface $sender)
119
    {
120
        $this->sender = $sender;
121
    }
122
123
    /**
124
     * {@inheritdoc}
125
     */
126
    public function getSender()
127
    {
128
        return $this->sender;
129
    }
130
131
    /**
132
     * {@inheritdoc}
133
     */
134
    public function addMessageMeta(MessageMetaInterface $messageMeta)
135
    {
136
        $messageMeta->setMessage($this);
137
        $this->messageMeta->add($messageMeta);
138
    }
139
140
    /**
141
     * {@inheritdoc}
142
     */
143
    public function getMessageMeta()
144
    {
145
        return $this->messageMeta;
146
    }
147
148
    /**
149
     * {@inheritdoc}
150
     */
151
    public function getMessageMetaForParticipant(ParticipantInterface $participant)
152
    {
153
        foreach ($this->messageMeta as $meta) {
154
            if ($meta->getParticipant()->getParticipantId() === $participant->getParticipantId()) {
155
                return $meta;
156
            }
157
        }
158
159
        return null;
160
    }
161
162
    /**
163
     * {@inheritdoc}
164
     */
165
    public function setThread(ThreadInterface $thread)
166
    {
167
        $this->thread = $thread;
168
    }
169
170
    /**
171
     * {@inheritdoc}
172
     */
173
    public function getThread()
174
    {
175
        return $this->thread;
176
    }
177
}
178