1. Go to this page and download the library: Download prvious/result 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/ */
prvious / result example snippets
declare(strict_types=1);
use Prvious\Result\Result;
/**
* @return Result<float, string>
*/
function divide(float $dividend, float $divisor): Result
{
if ($divisor === 0.0) {
return Result::err('Cannot divide by zero.');
}
return Result::ok($dividend / $divisor);
}