1. Go to this page and download the library: Download carlosupreme/error-or library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
carlosupreme / error-or example snippets
use Carlosupreme\ErrorOr\Error;
// Creating a failure error
$error = Error::failure();
// Creating an unexpected error
$error = Error::unexpected();
// Creating a validation error
$error = Error::validation('validation_code', 'Validation failed.');
echo $error->getCode(); // Outputs the error code
echo $error->getDescription(); // Outputs the error description
echo $error->getType(); // Outputs the error type
use Carlosupreme\ErrorOr\ErrorOr;
// From a value
$result = ErrorOr::fromValue('some value');
// From a single error
$errorResult = ErrorOr::fromError($error);
// From multiple errors
$multiErrorResult = ErrorOr::fromErrors($error1, $error2);