Failed Conditions
Push — master ( ab912b...01f77f )
by Adrien
10:12
created

Message   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 10
c 0
b 0
f 0
dl 0
loc 37
rs 10
ccs 10
cts 10
cp 1
wmc 4

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setRecipient() 0 11 3
A getRecipient() 0 3 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Application\Model;
6
7
use Doctrine\ORM\Mapping as ORM;
8
use GraphQL\Doctrine\Annotation as API;
9
10
/**
11
 * A message sent to a user
12
 *
13
 * @ORM\Entity(repositoryClass="Application\Repository\MessageRepository")
14
 */
15
class Message extends AbstractModel implements \Ecodev\Felix\Model\Message
16
{
17
    use \Ecodev\Felix\Model\Traits\Message;
18
19
    /**
20
     * @var null|User
21
     *
22
     * @ORM\ManyToOne(targetEntity="User", inversedBy="messages")
23
     * @ORM\JoinColumns({
24
     *     @ORM\JoinColumn(onDelete="CASCADE")
25
     * })
26
     */
27
    private $recipient;
28
29
    /**
30
     * Set recipient
31
     */
32 11
    public function setRecipient(?User $recipient): void
33
    {
34 11
        if ($this->recipient) {
35 1
            $this->recipient->messageRemoved($this);
36
        }
37
38 11
        $this->recipient = $recipient;
39 11
        $this->setOwner($recipient);
40
41 11
        if ($this->recipient) {
42 11
            $this->recipient->messageAdded($this);
43
        }
44 11
    }
45
46
    /**
47
     * Get recipient
48
     */
49 5
    public function getRecipient(): ?User
50
    {
51 5
        return $this->recipient;
52
    }
53
}
54