ILIAS  trunk Revision v12.0_alpha-377-g3641b37b9db
PersonalSettingsTemplate.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
24
26{
27 public function __construct(
28 private int $id,
29 private int $user_id,
30 private string $name,
31 private string $description,
32 private string $author,
33 private \DateTimeImmutable $created_at,
34 private int $settings_id = -1
35 ) {
36 }
37
38 public function getId(): int
39 {
40 return $this->id;
41 }
42
43 public function withId(int $id): self
44 {
45 $clone = clone $this;
46 $clone->id = $id;
47 return $clone;
48 }
49
50 public function getUserId(): int
51 {
52 return $this->user_id;
53 }
54
55 public function withUserId(int $user_id): self
56 {
57 $clone = clone $this;
58 $clone->user_id = $user_id;
59 return $clone;
60 }
61
62 public function getName(): string
63 {
64 return $this->name;
65 }
66
67 public function getDescription(): string
68 {
69 return $this->description;
70 }
71
72 public function getAuthor(): string
73 {
74 return $this->author;
75 }
76
77 public function getCreatedAt(): \DateTimeImmutable
78 {
79 return $this->created_at;
80 }
81
82 public function getSettingsId(): int
83 {
84 return $this->settings_id;
85 }
86
87 public function toExport(): array
88 {
89 return [
90 'id' => $this->getId(),
91 'user_id' => $this->getUserId(),
92 'name' => $this->getName(),
93 'description' => $this->getDescription(),
94 'author' => $this->getAuthor(),
95 'created_at' => $this->getCreatedAt()->format(\DateTimeInterface::ATOM),
96 ];
97 }
98
99 public static function fromExport(array $data): static
100 {
101 return new self(
102 (int) $data['id'],
103 (int) $data['user_id'],
104 (string) $data['name'],
105 (string) $data['description'],
106 (string) $data['author'],
107 new \DateTimeImmutable($data['created_at'])
108 );
109 }
110}
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Definition: plugin.php:23
__construct(private int $id, private int $user_id, private string $name, private string $description, private string $author, private \DateTimeImmutable $created_at, private int $settings_id=-1)
static fromExport(array $data)
Creates an instance of the object from an array.
toExport()
Transform the object into a simple, associative array.
This interface allows an object to define its own transformation into a language-neutral,...
Definition: Exportable.php:40
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...