Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 2 |
CRAP | |
0.00% |
0 / 15 |
| WeatherAPIController | |
0.00% |
0 / 1 |
|
0.00% |
0 / 2 |
12.00 | |
0.00% |
0 / 15 |
| initialize | |
0.00% |
0 / 1 |
2.00 | |
0.00% |
0 / 4 |
|||
| indexActionGet | |
0.00% |
0 / 1 |
6.00 | |
0.00% |
0 / 11 |
|||
| <?php | |
| namespace Abbe\Controller; | |
| use Abbe\Models\OpenWeather; | |
| use Anax\Commons\ContainerInjectableInterface; | |
| use Anax\Commons\ContainerInjectableTrait; | |
| use Exception; | |
| class WeatherAPIController 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() | |
| { | |
| $ipAddress = $this->di->request->getGet('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; | |
| return json_encode($data); | |
| } | |
| } |