Community::getUpdatedAt()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App\Entity\Community;
4
5
use Doctrine\ORM\Mapping as ORM;
6
7
use App\Entity\Picture;
8
9
/**
10
 * @ORM\Entity(repositoryClass="App\Repository\Community\CommunityRepository")
11
 * @ORM\Table(name="communities__community")
12
 * @ORM\HasLifecycleCallbacks
13
 */
14
class Community implements \JsonSerializable
15
{
16
    /**
17
     * @ORM\Id
18
     * @ORM\GeneratedValue(strategy="AUTO")
19
     * @ORM\Column(type="integer")
20
     **/
21
    protected $id;
22
    /**
23
     * @ORM\Column(type="string", length=255, unique=true)
24
     **/
25
    protected $name;
26
    /**
27
     * @ORM\Column(type="string", length=255, unique=true)
28
     */
29
    protected $slug;
30
    /**
31
     * @ORM\OneToOne(targetEntity="App\Entity\Picture", cascade={"persist", "remove"})
32
     * @ORM\JoinColumn(nullable=true)
33
     **/
34
    protected $picture;
35
    /**
36
     * @ORM\Column(type="datetime")
37
     **/
38
    protected $createdAt;
39
    /**
40
     * @ORM\Column(type="datetime")
41
     **/
42
    protected $updatedAt;
43
    
44
    /**
45
     * @ORM\PrePersist()
46
     */
47 3
    public function prePersist()
48
    {
49 3
        $this->createdAt = $this->updatedAt = new \DateTime();
50 3
    }
51
    
52
    /**
53
     * @ORM\PreUpdate()
54
     */
55 1
    public function preUpdate()
56
    {
57 1
        $this->updatedAt = new \DateTime();
58 1
    }
59
    
60
    /**
61
     * @param int $id
62
     * @return \Community
0 ignored issues
show
Bug introduced by
The type Community was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
63
     */
64 6
    public function setId(int $id): Community
65
    {
66 6
        $this->id = $id;
67
        
68 6
        return $this;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this returns the type App\Entity\Community\Community which is incompatible with the documented return type Community.
Loading history...
69
    }
70
    
71
    /**
72
     * @return int
73
     */
74 1
    public function getId(): int
75
    {
76 1
        return $this->id;
77
    }
78
    
79
    /**
80
     * @param string $name
81
     * @return Community
82
     */
83 8
    public function setName(string $name): Community
84
    {
85 8
        $this->name = $name;
86
        
87 8
        return $this;
88
    }
89
    
90
    /**
91
     * @return string
92
     */
93 4
    public function getName(): string
94
    {
95 4
        return $this->name;
96
    }
97
    
98
    /**
99
     * @param string $slug
100
     * @return Community
101
     */
102 4
    public function setSlug(string $slug): Community
103
    {
104 4
        $this->slug = $slug;
105
        
106 4
        return $this;
107
    }
108
    
109
    /**
110
     * @return string
111
     */
112 3
    public function getSlug(): string
113
    {
114 3
        return $this->slug;
115
    }
116
    
117
    /**
118
     * @param Picture $picture
119
     * @return Community
120
     */
121 2
    public function setPicture(Picture $picture): Community
122
    {
123 2
        $this->picture = $picture;
124
        
125 2
        return $this;
126
    }
127
    
128
    /**
129
     * @return Picture
130
     */
131 2
    public function getPicture(): ?Picture
132
    {
133 2
        return $this->picture;
134
    }
135
    
136
    /**
137
     * @param \DateTime $createdAt
138
     * @return Community
139
     */
140 1
    public function setCreatedAt(\DateTime $createdAt): Community
141
    {
142 1
        $this->createdAt = $createdAt;
143
        
144 1
        return $this;
145
    }
146
    
147
    /**
148
     * @return \DateTime
149
     */
150 2
    public function getCreatedAt(): \DateTime
151
    {
152 2
        return $this->createdAt;
153
    }
154
    
155
    /**
156
     * @param \DateTime $updatedAt
157
     * @return Community
158
     */
159 1
    public function setUpdatedAt(\DateTime $updatedAt): Community
160
    {
161 1
        $this->updatedAt = $updatedAt;
162
        
163 1
        return $this;
164
    }
165
    
166
    /**
167
     * @return \DateTime
168
     */
169 3
    public function getUpdatedAt(): \DateTime
170
    {
171 3
        return $this->updatedAt;
172
    }
173
    
174 1
    public function jsonSerialize()
175
    {
176
        return [
177 1
            'id' => $this->id,
178 1
            'name' => $this->name,
179 1
            'slug' => $this->slug,
180 1
            'picture' => $this->picture,
181 1
            'created_at' => $this->createdAt,
182 1
            'updated_at' => $this->updatedAt
183
        ];
184
    }
185
}