1. Go to this page and download the library: Download ustream/option 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/ */
ustream / option example snippets
$result = someMethodReturningAnOptionalString($params)
->apply(
function ($result) {
return $result . ' is a string!';
})
->getOrElse('default');
$module = $dataMaybe
->apply(
function ($data) {
if (isset($data['moduleConfig'])) {
if (count($data['moduleConfig']) == 1) {
return key($data['moduleConfig']);
} elseif (count($data['moduleConfig']) > 1) {
return 'full';
}
}
}
)
->getOrElse('unknown');
header(
locate($_SERVER["DOCUMENT_URI"])
->apply(
function ($location) {
statsdIncrement('302');
return 'Location: ' . $location;
}
)
->otherwise(
function () {
statsdIncrement('404');
}
)
->getOrElse("HTTP/1.0 404 Not Found")
);