Stop::getId()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
c 0
b 0
f 0
rs 10
cc 1
eloc 1
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Itmedia\ZippyBusBundle\Schedule;
6
7
/**
8
 * Остановка
9
 */
10
class Stop implements SlugAware
11
{
12
13
    /**
14
     * @var int
15
     */
16
    private $id;
17
18
    /**
19
     * @var string
20
     */
21
    private $name;
22
23
    /**
24
     * @var string
25
     */
26
    private $slug;
27
28
    /**
29
     * @var StopTime[]
30
     */
31
    private $times = [];
32
33
    /**
34
     * Stop constructor.
35
     * @param int $id
36
     * @param string $name
37
     * @param string $slug
38
     * @param StopTime[] $times
39
     */
40
    public function __construct(int $id, string $name, string $slug, array $times)
41
    {
42
        $this->id = $id;
43
        $this->name = $name;
44
        $this->slug = $slug;
45
        $this->times = $times;
46
    }
47
48
    /**
49
     * @return int
50
     */
51
    public function getId(): int
52
    {
53
        return $this->id;
54
    }
55
56
    /**
57
     * @return string
58
     */
59
    public function getName(): string
60
    {
61
        return $this->name;
62
    }
63
64
    /**
65
     * @return string
66
     */
67
    public function getSlug(): string
68
    {
69
        return $this->slug;
70
    }
71
72
    /**
73
     * @return StopTime[]
74
     */
75
    public function getTimes(): array
76
    {
77
        return $this->times;
78
    }
79
80
81
    public function getNearStopTime(StopTime $currentTime): ?StopTime
82
    {
83
        foreach ($this->times as $time) {
84
            if ($currentTime->getTime() < $time->getTime()) {
85
                return $time;
86
            }
87
        }
88
89
        return null;
90
    }
91
}
92