Skip to content

Commit 5d9d563

Browse files
authored
Add createdAt property + setter and getter
"createdAt" property and "setCreatedAt" is not defined on section "Using Callbacks to Serialize Properties with Object Instances" so the PHP Fatal error is triggered: Call to undefined method Person::setCreatedAt()
1 parent 1bb1a68 commit 5d9d563

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

components/serializer.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ exists in your project::
7272
private $age;
7373
private $name;
7474
private $sportsman;
75+
private $createdAt;
7576

7677
// Getters
7778
public function getName()
@@ -84,6 +85,11 @@ exists in your project::
8485
return $this->age;
8586
}
8687

88+
public function getCreatedAt()
89+
{
90+
return $this->createdAt;
91+
}
92+
8793
// Issers
8894
public function isSportsman()
8995
{
@@ -105,6 +111,11 @@ exists in your project::
105111
{
106112
$this->sportsman = $sportsman;
107113
}
114+
115+
public function setCreatedAt($createdAt)
116+
{
117+
$this->createdAt = $createdAt;
118+
}
108119
}
109120

110121
Now, if you want to serialize this object into JSON, you only need to

0 commit comments

Comments
 (0)