Skip to content

Instantly share code, notes, and snippets.

@tsh-code
Forked from szyku/resultobject.php
Created June 10, 2019 09:40
Show Gist options
  • Save tsh-code/bed1d4a1bf76a020acd4c1fe574edc9a to your computer and use it in GitHub Desktop.
Save tsh-code/bed1d4a1bf76a020acd4c1fe574edc9a to your computer and use it in GitHub Desktop.
Result Object
<?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