/** * @param string $method * @return \Closure */ function hasMethod($method) { if (!is_string($method)) { return never(); } return combine(pool(isObject(), combine(isString(), 'class_exists')), function ($object) use($method) { return method_exists($object, $method); }); }
function baseType($value) { if (isString($value)) { return 'string'; } if (isInteger($value)) { return 'integer'; } return 'object'; }
} return true; }; // Validates data $validates = function ($json) { if ($json === NULL) { returns(error('Body request not found')); return false; } if (!isString($json->{'name'})) { returns(error('Name field is empty')); return false; } if (!isEmail($json->{'email'})) { returns(error('E-mail field is empty')); return false; } if (!isString($json->{'password'})) { returns(error('Password field is empty')); return false; } return true; }; // Now, read it as a human and execute our orders :) $theData = $jsonFrom($input()); if ($validates($theData)) { $token = $saves($theData); if ($sendmail($token, $theData->{'email'})) { returns(success()); } }
function isEmail($email) { return isString($email) && filter_var($email, FILTER_VALIDATE_EMAIL); }
function fIsString() { return function ($d) { return isString($d); }; }
function saveBusListAsJson($array) { $buses = []; foreach ($array as $key => $value) { array_push($buses, ["Route" => $key, "Count" => count($array[$key]), "DisplayText" => (isString($key) ? "train" : "bus") . (count($array[$key]) > 1 ? isString($key) ? "s" : "es" : ""), "Bus" => isString($key) ? "false" : "true", "Selected" => "false"]); } file_put_contents(Constants::DATA_DIR . "buslist.json", json_encode(recursiveMapToString($buses))); }
/** * @return \Closure */ function isNotString() { return negate(isString()); }