-
-
Save tsh-code/bed1d4a1bf76a020acd4c1fe574edc9a 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