ThreadMeta   A
last analyzed

Complexity

Total Complexity 15

Size/Duplication

Total Lines 170
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 15
lcom 0
cbo 0
dl 0
loc 170
rs 10
c 0
b 0
f 0

14 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getId() 0 4 1
A setThread() 0 4 1
A getThread() 0 4 1
A setParticipant() 0 4 1
A getParticipant() 0 4 1
A getStatus() 0 4 1
A setStatus() 0 8 2
A setLastParticipantMessageDate() 0 4 1
A getLastParticipantMessageDate() 0 4 1
A getLastMessageDate() 0 4 1
A setLastMessageDate() 0 4 1
A getUnreadMessageCount() 0 4 1
A setUnreadMessageCount() 0 4 1
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
15
/**
16
 * The thread meta model
17
 *
18
 * @author Michiel Boeckaert <[email protected]>
19
 */
20
abstract class ThreadMeta implements ThreadMetaInterface
0 ignored issues
show
Coding Style introduced by
ThreadMeta 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...
21
{
22
    /**
23
     * The unique id of the thread
24
     *
25
     * @var integer
26
     */
27
    protected $id;
28
29
    /**
30
     * The thread this meta belongs to
31
     *
32
     * @var ThreadInterface
33
     */
34
    protected $thread;
35
36
    /**
37
     * The participant of the thread meta
38
     *
39
     * @var ParticipantInterface
40
     */
41
    protected $participant;
42
43
    /**
44
     * The status of the given thread for the participant
45
     *
46
     * @var string
47
     */
48
    protected $status;
49
50
    /**
51
     * Datetime of the last message written by the participant
52
     *
53
     * @var \DateTime
54
     */
55
    protected $lastParticipantMessageDate;
56
57
    /**
58
     * Datetime of the last message written by another participant
59
     *
60
     * @var \DateTime
61
     */
62
    protected $lastMessageDate;
63
64
    /**
65
     * The number of unread messages for the participant for the given thread.
66
     *
67
     * @var integer
68
     */
69
    protected $unreadMessageCount = 0;
70
71
    /**
72
     * Constructor.
73
     */
74
    public function __construct()
75
    {
76
        $this->status = ThreadMetaInterface::STATUS_ACTIVE;
77
    }
78
79
    /**
80
     * Gets the unique id
81
     *
82
     * @return integer|null
83
     */
84
    public function getId()
85
    {
86
        return $this->id;
87
    }
88
89
    /**
90
     * {@inheritdoc}
91
     */
92
    public function setThread(ThreadInterface $thread)
93
    {
94
        $this->thread = $thread;
95
    }
96
97
    /**
98
     * {@inheritdoc}
99
     */
100
    public function getThread()
101
    {
102
        return $this->thread;
103
    }
104
105
    /**
106
     * {@inheritdoc}
107
     */
108
    public function setParticipant(ParticipantInterface $participant)
109
    {
110
        $this->participant = $participant;
111
    }
112
113
    /**
114
     * {@inheritdoc}
115
     */
116
    public function getParticipant()
117
    {
118
        return $this->participant;
119
    }
120
121
    /**
122
     * {@inheritdoc}
123
     */
124
    public function getStatus()
125
    {
126
        return $this->status;
127
    }
128
129
    /**
130
     * {@inheritdoc}
131
     * @param $status
132
     */
133
    public function setStatus($status)
134
    {
135
        if (!in_array($status, [ThreadMetaInterface::STATUS_ACTIVE, ThreadMetaInterface::STATUS_ARCHIVED], true)) {
136
            throw new \InvalidArgumentException('Not a valid status');
137
        }
138
139
        $this->status = $status;
0 ignored issues
show
Documentation Bug introduced by
The property $status was declared of type string, but $status is of type integer. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
140
    }
141
142
    /**
143
     * {@inheritdoc}
144
     */
145
    public function setLastParticipantMessageDate(\DateTime $dateTime)
146
    {
147
        $this->lastParticipantMessageDate = $dateTime;
148
    }
149
150
    /**
151
     * {@inheritdoc}
152
     */
153
    public function getLastParticipantMessageDate()
154
    {
155
        return $this->lastParticipantMessageDate;
156
    }
157
158
    /**
159
     * {@inheritdoc}
160
     */
161
    public function getLastMessageDate()
162
    {
163
        return $this->lastMessageDate;
164
    }
165
166
    /**
167
     * {@inheritdoc}
168
     */
169
    public function setLastMessageDate(\DateTime $lastMessageDate)
170
    {
171
        $this->lastMessageDate = $lastMessageDate;
172
    }
173
174
    /**
175
     * {@inheritdoc}
176
     */
177
    public function getUnreadMessageCount()
178
    {
179
        return $this->unreadMessageCount;
180
    }
181
182
    /**
183
     * {@inheritdoc}
184
     */
185
    public function setUnreadMessageCount($unreadCount)
186
    {
187
        $this->unreadMessageCount = intval($unreadCount);
188
    }
189
}
190