Issues (5)

src/Controller/WeatherController.php (1 issue)

Labels
Severity
1
<?php
2
namespace Oliver\Controller;
3
4
use Anax\Commons\ContainerInjectableInterface;
5
use Anax\Commons\ContainerInjectableTrait;
6
7
use Oliver\Weather\Weather;
8
use Oliver\Weather\Exception\BadFormatException;
9
use Oliver\DarkSky\Exception\InvalidLocationException;
10
use Oliver\DarkSky\Exception\NoHistoryException;
0 ignored issues
show
The type Oliver\DarkSky\Exception\NoHistoryException was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
11
12
/**
13
 *
14
 */
15
class WeatherController implements ContainerInjectableInterface
16
{
17
    use ContainerInjectableTrait;
18
19
    private $title = "Väder";
20
    private $description = "<p>Sök efter en plats och få en väderprognos för den kommande veckan eller historik 30 dagar tillbaka.";
21
22
23 1
    public function indexActionGet() : object
24
    {
25 1
        $page = $this->di->get("page");
26 1
        $page->add("weather/index", [
27 1
            "title" => $this->title,
28 1
            "description" => $this->description
29
        ]);
30 1
        return $page->render([
31 1
            "title" => $this->title
32
        ]);
33
    }
34
35
36 2
    public function indexActionPost() : object
37
    {
38 2
        $request = $this->di->get("request");
39 2
        $page = $this->di->get("page");
40 2
        $session = $this->di->get("session");
41 2
        $darkSky = $this->di->get("darkSky");
42
43 2
        $coordinates = $request->getPost("coordinates");
44 2
        $option = $request->getPost("option");
45
46 2
        $page->add("weather/index", [
47 2
            "title" => $this->title,
48 2
            "description" => $this->description
49
        ]);
50
51
        try {
52 2
            $weather = new Weather($darkSky);
53 2
            $result = $weather->fetchWeather($coordinates, $option);
54 1
            $page->add("weather/$option", [
55 1
                "weather" => $result
56
            ]);
57 1
        } catch (BadFormatException | InvalidLocationException | NoHistoryException $e) {
58 1
            $session->set("flashmessage", $e->getMessage());
59
        }
60 2
        return $page->render([
61 2
            "title" => $this->title
62
        ]);
63
    }
64
}
65