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.

Revisions

  1. RayhanYulanda revised this gist Nov 23, 2020. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion User.php
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,4 @@
    <?php

    class User {
    public $name;
    public $email;
  2. RayhanYulanda revised this gist Nov 23, 2020. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion User.php
    Original file line number Diff line number Diff line change
    @@ -13,6 +13,7 @@ public function formatJson() {
    }
    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");
    if (!isset($data['email'])) { new \Exception("Bad Request, User Email Required")};
    }
    }
    ?>
  3. RayhanYulanda revised this gist Nov 23, 2020. 1 changed file with 17 additions and 2 deletions.
    19 changes: 17 additions & 2 deletions User.php
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,18 @@
    class User {
    <?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");
    }
    ?>
  4. RayhanYulanda created this gist Nov 16, 2020.
    3 changes: 3 additions & 0 deletions User.php
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    class User {

    }