- Merged multiple sub-libraries

This commit is contained in:
mcndave committed 2023-11-17 19:47:24 +00:00
1 parent 767152e0c3
commit cee97fca25
17 files changed
+787

No files matched your search

+37
View File
@@ -0,0 +1,37 @@
<?php
namespace Notes\Route\Attribute\Method;
#[\Attribute(\Attribute::IS_REPEATABLE | \Attribute::TARGET_METHOD)]
class Route implements \Notes\Attribute {
public function __construct(
public string $route,
public string $name,
public string|array $method = [ "GET", "POST" ],
public string $base = "",
public ? string $class = null,
public ? string $classMethod = null,
public bool $currentRoute = false,
) {}
public function getRoute() : string
{
return rtrim("/" . trim(isset($this->base) ?
"/" . trim($this->base, "/") . "/" . ltrim($this->route, "/")
:
"/" . ltrim($this->route, "/"), "/"), '/');
}
public function matchRouteName(string $name) : bool
{
return strtolower($this->name) === strtolower($name);
}
public function isRoute(string $name) {
return $this->name === $name;
}
public function currentRoute(bool|null $value = null ) {
return is_null($value) ? $value : $this->currentRoute = $value;
}
}