diff options
| author | Kevin J Hoerr <kjhoerr@protonmail.com> | 2017-07-08 11:11:53 -0400 |
|---|---|---|
| committer | Kevin J Hoerr <kjhoerr@protonmail.com> | 2017-07-08 11:11:53 -0400 |
| commit | 2d796d48df6f4371111bcbc776ea781e4f45c831 (patch) | |
| tree | 8b70da2114d71d2835b2f58eb2d43083a3ff5a6f /private/Controller | |
| parent | 3b75177580e536ce309d44759eb4d1f772c987ce (diff) | |
| download | august-offensive-2d796d48df6f4371111bcbc776ea781e4f45c831.tar.gz august-offensive-2d796d48df6f4371111bcbc776ea781e4f45c831.tar.bz2 august-offensive-2d796d48df6f4371111bcbc776ea781e4f45c831.zip | |
Expand on query and result, begin sql design
Diffstat (limited to 'private/Controller')
| -rw-r--r-- | private/Controller/Controller.php | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/private/Controller/Controller.php b/private/Controller/Controller.php new file mode 100644 index 0000000..188345a --- /dev/null +++ b/private/Controller/Controller.php @@ -0,0 +1,56 @@ +<?php + +declare(strict_types=1); + +namespace AugustOffensive\Controller; + +use AugustOffensive\Model; + +/** + * Static controller class for interfacing between the view and the model. + */ +class Controller +{ + /** + * Creates and returns a Query object. + * + * If the creation results in an error, a different query object is + * returned with the error message. + * + * @param array $path The array that holds the original request structure. + * @param string $request The request method made to the server. + * @param array $content The content object sent by the request. + * + * @return Model\Query + */ + public static function createQuery ( + array $path, + string $request, + array $content + ): Model\Query { + try { + return new Model\Query ($path, $request, $content); + } catch (\Exception $err) { + return new Model\Query (array(), "", array("ERROR" => $err->getMessage())); + } + } + + /** + * Creates and returns a Result object. + * + * @param string $resultType The type of result to send back to the client. + * @param array $result The result object to send back to the client. + * + * @return Model\Result + */ + public static function createResult ( + string $resultType, + array $result + ): Model\Result { + try { + return new Model\Result ($resultType, $result); + } catch (\Exception $err) { + return new Model\Result ("ERROR", array($err->getMessage())); + } + } +} |
