Skip to content

Commit

Permalink
Update readme.md
Browse files Browse the repository at this point in the history
  • Loading branch information
RyanDaDeng authored Aug 9, 2019
1 parent 8648c5b commit 016e716
Showing 1 changed file with 81 additions and 0 deletions.
81 changes: 81 additions & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,87 @@ Note: each object should have key name defined.

### Output - Classes:


#### User Class
````php

class User
{
/** @var $firstName */
public $firstName;

/** @var $lastName */
public $lastName;


/**
* @return User
*/
public static function create()
{
return new self;
}


/**
* @return array
*/
public function toArray(): array
{
return [
'first_name' => $this->firstName,
'last_name' => $this->lastName,
];
}
}

````

#### Comment Class
````php

class Comment
{
/** @var User $user */
public $user;

/** @var $content */
public $content;


/**
* @return Comment
*/
public static function create()
{
return new self;
}


/**
* @param User $user
* @return $this
*/
public function addUser($user)
{
$this->user = $user;
return $this;
}


/**
* @return array
*/
public function toArray(): array
{
return [
'user' => $this->user->toArray(),
'content' => $this->content,
];
}
}

````
#### Author Class
````php
<?php
Expand Down

0 comments on commit 016e716

Please sign in to comment.