ppshobi /
openweathermap
| 1 | <?php |
||
| 2 | |||
| 3 | namespace Shobi\Weatherapp\Weather; |
||
| 4 | |||
| 5 | use Shobi\Weatherapp\Weather\Units\Temperature; |
||
| 6 | |||
| 7 | class Weather |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * @var Shobi\Weatherapp\Weather\Units\Temperature |
||
|
0 ignored issues
–
show
Bug
introduced
by
Loading history...
|
|||
| 11 | */ |
||
| 12 | private $temperature; |
||
| 13 | |||
| 14 | /** |
||
| 15 | * the weather summary |
||
| 16 | * @var string |
||
| 17 | */ |
||
| 18 | private $summary; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @var string |
||
| 22 | */ |
||
| 23 | private $location; |
||
| 24 | |||
| 25 | /** |
||
| 26 | * Weather constructor. |
||
| 27 | * @param string $summary |
||
| 28 | * @param string $temperature |
||
| 29 | * @param string $location |
||
| 30 | */ |
||
| 31 | public function __construct(string $summary, string $temperature, string $location) |
||
| 32 | { |
||
| 33 | $this->temperature = new Temperature($temperature); |
||
|
0 ignored issues
–
show
It seems like
new Shobi\Weatherapp\Wea...mperature($temperature) of type Shobi\Weatherapp\Weather\Units\Temperature is incompatible with the declared type Shobi\Weatherapp\Weather...ather\Units\Temperature of property $temperature.
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property. Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property.. Loading history...
|
|||
| 34 | $this->location = $location; |
||
| 35 | $this->summary = $summary; |
||
| 36 | } |
||
| 37 | |||
| 38 | /** |
||
| 39 | * Returns the Temperature |
||
| 40 | * |
||
| 41 | * @return \Shobi\Weatherapp\Weather\Units\Temperature |
||
| 42 | */ |
||
| 43 | public function getTemperature(): Temperature |
||
| 44 | { |
||
| 45 | return $this->temperature; |
||
| 46 | } |
||
| 47 | /** |
||
| 48 | * Returns the weather summary |
||
| 49 | * |
||
| 50 | * @return string |
||
| 51 | */ |
||
| 52 | public function getSummary(): string |
||
| 53 | { |
||
| 54 | return $this->summary; |
||
| 55 | } |
||
| 56 | /** |
||
| 57 | * Returns the location |
||
| 58 | * |
||
| 59 | * @return string |
||
| 60 | */ |
||
| 61 | public function getLocation(): string |
||
| 62 | { |
||
| 63 | return $this->location; |
||
| 64 | } |
||
| 65 | |||
| 66 | /** |
||
| 67 | * @return string |
||
| 68 | */ |
||
| 69 | public function __toString(): string |
||
| 70 | { |
||
| 71 | return $this->temperature->toDegreeCelsius() |
||
| 72 | . " Degree celsius with " |
||
| 73 | . $this->summary |
||
| 74 | . " in " |
||
| 75 | . $this->location; |
||
| 76 | } |
||
| 77 | } |