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

City   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 54
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 0
dl 0
loc 54
ccs 0
cts 27
cp 0
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 7 1
A calculateDevaluationCostForCity() 0 4 1
A getCityId() 0 4 1
A getName() 0 4 1
A getDistance() 0 4 1
A getDevaluationCost() 0 4 1
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