Passed
Push — master ( 673bfc...65df8d )
by Julito
09:32
created

UserCreatorTrait   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 24
rs 10
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getCreator() 0 7 2
A getResourceNodeCreator() 0 3 1
A setCreator() 0 5 1
1
<?php
2
3
declare(strict_types=1);
4
5
/* For licensing terms, see /license.txt */
6
7
namespace Chamilo\CoreBundle\Traits;
8
9
use Chamilo\CoreBundle\Entity\ResourceNode;
10
use Chamilo\CoreBundle\Entity\User;
11
12
trait UserCreatorTrait
13
{
14
    public ?ResourceNode $resourceNode = null;
15
    public ?User $resourceNodeCreator = null;
16
17
    public function getCreator(): ?User
18
    {
19
        if (null === $this->resourceNode) {
20
            return null;
21
        }
22
23
        return $this->resourceNode->getCreator();
24
    }
25
26
    public function setCreator(User $user)
27
    {
28
        $this->resourceNodeCreator = $user;
29
30
        return $this;
31
    }
32
33
    public function getResourceNodeCreator(): ?User
34
    {
35
        return $this->resourceNodeCreator;
36
    }
37
}
38