Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 15 |
| WeatherController | |
0.00% |
0 / 1 |
|
0.00% |
0 / 3 |
20.00 | |
0.00% |
0 / 15 |
| initialize | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 3 |
|||
| indexActionGet | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 3 |
|||
| indexActionPost | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 9 |
|||
| <?php | |
| namespace Abbe\Controller; | |
| use Anax\Commons\ContainerInjectableInterface; | |
| use Anax\Commons\ContainerInjectableTrait; | |
| use Exception; | |
| class WeatherController implements ContainerInjectableInterface | |
| { | |
| use ContainerInjectableTrait; | |
| /** | |
| * @var string $db a sample member variable that gets initialised | |
| */ | |
| private $db = "not active"; | |
| public function initialize() : void | |
| { | |
| // Use to initialise member variables. | |
| $this->db = "active"; | |
| $this->page = $this->di->get("page"); | |
| } | |
| public function indexActionGet() | |
| { | |
| $data = [ | |
| "name" => "test" | |
| ]; | |
| $this->page->add('mine/weather/index', $data); | |
| return $this->page->render(["title" => "Weather report"]); | |
| } | |
| public function indexActionPost() | |
| { | |
| $ipAddress = $this->di->request->getPost('ip') ?? ""; | |
| try { | |
| $te1 = $this->di->get("weather"); | |
| $data = $te1->requestData($ipAddress); | |
| } catch (Exception $e) { | |
| $data["message"] = "Something is wrong with the specified IP address. Please try again."; | |
| } | |
| $data["specifiedIP"] = $ipAddress; | |
| $data["name"] = "Weather"; | |
| $this->page->add('mine/weather/index', $data); | |
| return $this->page->render(["title" => "Weather report"]); | |
| } | |
| } |