From 96ce850b5369b4e4ad0d4aa8db15dbcf732d7fcf Mon Sep 17 00:00:00 2001 From: Brady McDonough Date: Sun, 28 Jan 2024 23:33:08 -0700 Subject: [PATCH] First pass of the RequestInterface and default implementation --- src/Request/base.php | 47 +++++++++++++++++++++++++++++++ src/Required/RequestInterface.php | 4 +-- src/Required/RequestTargets.php | 11 ++++++++ 3 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 src/Request/base.php create mode 100644 src/Required/RequestTargets.php diff --git a/src/Request/base.php b/src/Request/base.php new file mode 100644 index 0000000..89222bb --- /dev/null +++ b/src/Request/base.php @@ -0,0 +1,47 @@ + $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]; + } + +} + +?> diff --git a/src/Required/RequestInterface.php b/src/Required/RequestInterface.php index be4bc51..855c22c 100644 --- a/src/Required/RequestInterface.php +++ b/src/Required/RequestInterface.php @@ -16,14 +16,14 @@ interface RequestInterface * @param string $place One of "enroll", "unenroll" or "authenticate" * @return string */ - function form_props(string $place): string; + public function form_props(string $place): string; /** * Returns a referred user response variable. * @param string $k The key the user is sending * @return string */ - function get_resp(string $k): string; + public function get_resp(string $k): string; } diff --git a/src/Required/RequestTargets.php b/src/Required/RequestTargets.php new file mode 100644 index 0000000..9bb8216 --- /dev/null +++ b/src/Required/RequestTargets.php @@ -0,0 +1,11 @@ +