Skip to content

Instantly share code, notes, and snippets.

@szyku
Created April 28, 2019 10:09
Show Gist options
  • Save szyku/65258b541b35e446c2f4fda07fc49cf8 to your computer and use it in GitHub Desktop.
Save szyku/65258b541b35e446c2f4fda07fc49cf8 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