Passed
Pull Request — master (#1)
by Mozammil
01:46
created

Weather   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 69
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 15
dl 0
loc 69
rs 10
c 0
b 0
f 0
wmc 5

5 Methods

Rating   Name   Duplication   Size   Complexity  
A getTemperature() 0 3 1
A getLocation() 0 3 1
A __toString() 0 7 1
A __construct() 0 5 1
A getSummary() 0 3 1
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
The type Shobi\Weatherapp\Weather...ather\Units\Temperature was not found. Did you mean Shobi\Weatherapp\Weather\Units\Temperature? If so, make sure to prefix the type with \.
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
Documentation Bug introduced by
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
}