2222 * @author Tatevik Grigoryan <[email protected] > 2323 */
2424#[ORM \Entity(repositoryClass: AdministratorRepository::class)]
25- #[ORM \Table(
26- name: 'phplist_admin ' ,
27- uniqueConstraints: [new ORM \UniqueConstraint (name: 'loginnameidx ' , columns: ['loginname ' ])]
28- )]
25+ #[ORM \Table(name: 'phplist_admin ' )]
26+ #[ORM \UniqueConstraint(name: 'loginnameidx ' , columns: ['loginname ' ])]
2927#[ORM \HasLifecycleCallbacks]
3028class Administrator implements DomainModel, Identity, CreationDate, ModificationDate
3129{
@@ -35,7 +33,7 @@ class Administrator implements DomainModel, Identity, CreationDate, Modification
3533 private ?int $ id = null ;
3634
3735 #[ORM \Column(name: 'created ' , type: 'datetime ' , nullable: true )]
38- protected ? DateTime $ createdAt = null ;
36+ protected DateTime $ createdAt ;
3937
4038 #[ORM \Column(name: 'modified ' , type: 'datetime ' , nullable: false )]
4139 private DateTime $ updatedAt ;
@@ -71,7 +69,6 @@ public function __construct()
7169 {
7270 $ this ->createdAt = new DateTime ();
7371 $ this ->updatedAt = new DateTime ();
74- $ this ->loginName = '' ;
7572 $ this ->email = '' ;
7673 }
7774
@@ -80,7 +77,7 @@ public function getId(): ?int
8077 return $ this ->id ;
8178 }
8279
83- public function getCreatedAt (): ? DateTime
80+ public function getCreatedAt (): DateTime
8481 {
8582 return $ this ->createdAt ;
8683 }
@@ -170,6 +167,8 @@ public function setPrivileges(Privileges $privileges): self
170167
171168 /**
172169 * @throws InvalidArgumentException
170+ *
171+ * @SuppressWarnings(PHPMD.StaticAccess)
173172 */
174173 public function setPrivilegesFromArray (array $ privilegesData ): void
175174 {
@@ -184,6 +183,7 @@ public function setPrivilegesFromArray(array $privilegesData): void
184183 $ this ->setPrivileges ($ privileges );
185184 }
186185
186+ /** @SuppressWarnings(PHPMD.StaticAccess) */
187187 public function getPrivileges (): Privileges
188188 {
189189 return Privileges::fromSerialized ($ this ->privileges );
@@ -209,17 +209,8 @@ public function owns(OwnableInterface $resource): bool
209209 return $ resource ->getOwner ()->getId () === $ this ->getId ();
210210 }
211211
212- #[ORM \PrePersist]
213- public function onPrePersist (): void
214- {
215- if ($ this ->createdAt === null ) {
216- $ this ->createdAt = new DateTime ();
217- }
218- $ this ->updatedAt = new DateTime ();
219- }
220-
221212 #[ORM \PreUpdate]
222- public function onPreUpdate (): void
213+ public function setUpdatedAt (): void
223214 {
224215 $ this ->updatedAt = new DateTime ();
225216 }
0 commit comments