Skip to content

Instantly share code, notes, and snippets.

@RayhanYulanda
Last active November 23, 2020 11:37
Show Gist options
  • Save RayhanYulanda/79ec1bfe302da41666698bb0bee2759c to your computer and use it in GitHub Desktop.
Save RayhanYulanda/79ec1bfe302da41666698bb0bee2759c to your computer and use it in GitHub Desktop.
User bad class
<?php
class User {
public $name;
public $email;
public function __construct($data) {
$this->name = $data['name'];
$this->email = $data['email'];
}
public function formatJson() {
return json_encode(['name' => $this->name, 'email' => $this->email]);
}
public function validate($data) {
if (!isset($data['name'])) { new \Exception("Bad Request, User Requires A Name")};
if (!isset($data['email'])) { new \Exception("Bad Request, User Email Required")};
}
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment