From 88fe7b7a0307f428ca3bcce7eddca5ad36b93e0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C5=91cze=20Bence?= Date: Sun, 31 May 2020 20:41:16 +0200 Subject: [PATCH] MAPG-86 refactor view-controller --- src/Interfaces/Controller/IController.php | 8 ---- .../{View/IView.php => Response/IContent.php} | 4 +- src/Interfaces/Response/IRedirect.php | 12 ++++++ .../ViewBase.php => Response/ContentBase.php} | 6 +-- .../HtmlView.php => Response/HtmlContent.php} | 4 +- .../JsonView.php => Response/JsonContent.php} | 4 +- src/Response/Redirect.php | 41 +++++++++++++++++++ 7 files changed, 62 insertions(+), 17 deletions(-) delete mode 100644 src/Interfaces/Controller/IController.php rename src/Interfaces/{View/IView.php => Response/IContent.php} (66%) create mode 100644 src/Interfaces/Response/IRedirect.php rename src/{View/ViewBase.php => Response/ContentBase.php} (62%) rename src/{View/HtmlView.php => Response/HtmlContent.php} (87%) rename src/{View/JsonView.php => Response/JsonContent.php} (80%) create mode 100644 src/Response/Redirect.php diff --git a/src/Interfaces/Controller/IController.php b/src/Interfaces/Controller/IController.php deleted file mode 100644 index 07caeeb..0000000 --- a/src/Interfaces/Controller/IController.php +++ /dev/null @@ -1,8 +0,0 @@ -target = $target; + $this->type = $type; + } + + public function getUrl(): string + { + if (is_array($this->target)) { + $link = $this->target[0]->generateLink($this->target[1]); + } else { + $link = $this->target; + } + + return $link; + } + + public function getHttpCode(): int + { + switch ($this->type) { + case IRedirect::PERMANENT: + return 301; + + case IRedirect::TEMPORARY: + return 302; + + default: + return 302; + } + } +}