This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class UserRequest { | |
protected static $rules = [ | |
'name' => 'string', | |
'email' => 'string' | |
]; | |
public static function validate($data){ | |
foreach(static::$rules as $property => $type){ | |
if (gettype($data[$property]) != $type) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class User { | |
public $name; | |
public $email; | |
public function __construct($data) { | |
$this->name = $data['name']; | |
$this->email = $data['email']; | |
} | |
public function formatJson() { |