/
Location.php
57 lines (47 loc) · 1.27 KB
/
Location.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
<?php
/*
* This file is part of the eluceo/iCal package.
*
* (c) 2021 Markus Poerschke <markus@poerschke.nrw>
*
* This source file is subject to the MIT license that is bundled
* with this source code in the file LICENSE.
*/
namespace Eluceo\iCal\Domain\ValueObject;
final class Location
{
private string $location;
private ?string $title;
private ?GeographicPosition $geographicPosition = null;
public function __construct(string $location, string $title = null)
{
$this->location = $location;
$this->title = $title;
}
public function withGeographicPosition(GeographicPosition $geographicPosition): self
{
$new = clone $this;
$new->geographicPosition = $geographicPosition;
return $new;
}
public function hasGeographicalPosition(): bool
{
return $this->geographicPosition !== null;
}
/**
* @psalm-suppress InvalidNullableReturnType
* @psalm-suppress NullableReturnStatement
*/
public function getGeographicPosition(): GeographicPosition
{
return $this->geographicPosition;
}
public function getTitle(): string
{
return (string) $this->title;
}
public function __toString(): string
{
return $this->location;
}
}