Created
October 25, 2017 20:18
-
-
Save peterlafferty/3d31994b60af61987e70bf3418b235ec to your computer and use it in GitHub Desktop.
basic silex controller for TDD
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| namespace pl\tddcontroller; | |
| use Symfony\Component\HttpFoundation\JsonResponse; | |
| class TddController | |
| { | |
| /** @var string */ | |
| private $charset; | |
| public function __construct(string $charset) | |
| { | |
| $this->charset = $charset; | |
| } | |
| public function get(int $id): JsonResponse | |
| { | |
| return new JsonResponse($id . $this->charset); | |
| } | |
| public function getAll(array $query): JsonResponse | |
| { | |
| $value = 'value1'; | |
| if (isset($query['returnsecondvalue']) && $query['returnsecondvalue'] === "true") { | |
| $value = 'value2'; | |
| } | |
| return new JsonResponse($value . $this->charset); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment