PHP code example of hershel-theodore-layton / lecof-router
1. Go to this page and download the library: Download hershel-theodore-layton/lecof-router 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/ */
hershel-theodore-layton / lecof-router example snippets
HACK
function literal_with_optional_extension<T as nonnull>(
string $literal,
string $extension,
LecofInterfaces\Filter<T> $next,
)[]: LecofInterfaces\Filter<T> {
return new LiteralWithOptionalExtension($literal, $extension, $next);
}
final class LiteralWithOptionalExtension<T as nonnull>
implements LecofInterfaces\Filter<T> {
public function __construct(
private string $literal,
private string $extension,
private LecofInterfaces\Filter<T> $next,
)[] {}
public function filter(
LecofInterfaces\RequestInfo $request_info,
int $index,
)[]: ?LecofInterfaces\RouteResult<T> {
$segment = $request_info->getPathSegment($index);
if (
$segment !== $this->literal &&
$segment !== $this->literal.$this->extension
) {
return null;
}
return $this->next->filter($request_info, $index + 1);
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.