Skip to content

Commit 016e716

Browse files
authored
Update readme.md
1 parent 8648c5b commit 016e716

File tree

1 file changed

+81
-0
lines changed

1 file changed

+81
-0
lines changed

readme.md

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,87 @@ Note: each object should have key name defined.
8080

8181
### Output - Classes:
8282

83+
84+
#### User Class
85+
````php
86+
87+
class User
88+
{
89+
/** @var $firstName */
90+
public $firstName;
91+
92+
/** @var $lastName */
93+
public $lastName;
94+
95+
96+
/**
97+
* @return User
98+
*/
99+
public static function create()
100+
{
101+
return new self;
102+
}
103+
104+
105+
/**
106+
* @return array
107+
*/
108+
public function toArray(): array
109+
{
110+
return [
111+
'first_name' => $this->firstName,
112+
'last_name' => $this->lastName,
113+
];
114+
}
115+
}
116+
117+
````
118+
119+
#### Comment Class
120+
````php
121+
122+
class Comment
123+
{
124+
/** @var User $user */
125+
public $user;
126+
127+
/** @var $content */
128+
public $content;
129+
130+
131+
/**
132+
* @return Comment
133+
*/
134+
public static function create()
135+
{
136+
return new self;
137+
}
138+
139+
140+
/**
141+
* @param User $user
142+
* @return $this
143+
*/
144+
public function addUser($user)
145+
{
146+
$this->user = $user;
147+
return $this;
148+
}
149+
150+
151+
/**
152+
* @return array
153+
*/
154+
public function toArray(): array
155+
{
156+
return [
157+
'user' => $this->user->toArray(),
158+
'content' => $this->content,
159+
];
160+
}
161+
}
162+
163+
````
83164
#### Author Class
84165
````php
85166
<?php

0 commit comments

Comments
 (0)