Created
April 28, 2019 10:09
-
-
Save szyku/65258b541b35e446c2f4fda07fc49cf8 to your computer and use it in GitHub Desktop.
Result Object
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 | |
final class ResultObject | |
{ | |
public $isSuccessful; | |
public $payload = null; | |
private function __construct(bool $isSuccessful, $payload = null) | |
{ | |
$this->isSuccessful = $isSuccessful; | |
$this->payload = $payload; | |
} | |
public static function fail() | |
{ | |
return new static(false); | |
} | |
public static function success($payload) | |
{ | |
return new static(true, $payload); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment