Completed
Push — lonja/eduard ( 66fb34 )
by Albert
05:35
created

City::calculateDevaluationCostForCity()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 4
cp 0
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 2
1
<?php
2
3
namespace Kata;
4
5
class City
6
{
7
    private $city_id;
8
    private $name;
9
    private $distance;
10
    private $devaluation_cost;
11
12
    public function __construct(int $city_id, string $name, int $distance)
13
    {
14
        $this->city_id          = $city_id;
15
        $this->name             = $name;
16
        $this->distance         = $distance;
17
        $this->devaluation_cost = $this->calculateDevaluationCostForCity($distance);
18
    }
19
20
    private function calculateDevaluationCostForCity(int $distance): float
21
    {
22
        return 0.01 * $distance;
23
    }
24
25
    /**
26
     * @return int
27
     */
28
    public function getCityId(): int
29
    {
30
        return $this->city_id;
31
    }
32
33
    /**
34
     * @return string
35
     */
36
    public function getName(): string
37
    {
38
        return $this->name;
39
    }
40
41
    /**
42
     * @return int
43
     */
44
    public function getDistance(): int
45
    {
46
        return $this->distance;
47
    }
48
49
    /**
50
     * @return float
51
     */
52
    public function getDevaluationCost(): float
53
    {
54
        return $this->devaluation_cost;
55
    }
56
57
58
}
59