parent
8d50708e93
commit
96ce850b53
@ -0,0 +1,47 @@
|
|||||||
|
<?php
|
||||||
|
namespace BradyMcD\TAATP\Request;
|
||||||
|
|
||||||
|
use BradyMcD\TAATP\Required\RequestInterface;
|
||||||
|
use BradyMcD\TAATP\Required\RequestTargets;
|
||||||
|
|
||||||
|
class Base implements RequestInterface
|
||||||
|
{
|
||||||
|
|
||||||
|
public function __construct(private mixed $paths)
|
||||||
|
{
|
||||||
|
if(\is_array($paths))
|
||||||
|
{
|
||||||
|
foreach($paths as $r => $p)
|
||||||
|
{
|
||||||
|
// ::from will throw a ValueError if invalid
|
||||||
|
RequestTargets::from($r);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(!\is_string($paths))
|
||||||
|
{
|
||||||
|
throw new \IllegalArgumentException("You must either provide a single path as a string or a list of RequestTargets as keys to paths.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public function form_props(string $place): string
|
||||||
|
{
|
||||||
|
$method = 'method="post"';
|
||||||
|
if(\is_array($this->paths))
|
||||||
|
{
|
||||||
|
$action = 'action="' . $this->paths[$place] . '"';
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
$action = 'action="' . $this->paths . '"';
|
||||||
|
}
|
||||||
|
return $action . ' ' . $method;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function get_resp(string $k): string
|
||||||
|
{
|
||||||
|
return $__REQUEST[$k];
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
@ -0,0 +1,11 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace BradyMcD\TAATP\Required;
|
||||||
|
|
||||||
|
enum RequestTargets: string{
|
||||||
|
case Authenticate = "authenticate";
|
||||||
|
case Enroll = "enroll";
|
||||||
|
case Unenroll = "unenroll";
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
||||||
Loading…
Reference in new issue