-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUrlShortened.php
70 lines (59 loc) · 1.47 KB
/
UrlShortened.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
58
59
60
61
62
63
64
65
66
67
68
69
70
<?php
declare(strict_types=1);
namespace LaSalle\UrlShortener\JudithVilela\UrlShortened\Domain\Model\Aggregate;
use DateTimeImmutable;
use LaSalle\UrlShortener\JudithVilela\UrlShortened\Domain\Model\ValueObject\UrlId;
use LaSalle\UrlShortener\JudithVilela\UrlShortened\Domain\Model\ValueObject\Url;
final class UrlShortened
{
/** @var UrlId */
private $id;
/** @var Url */
private $urlOriginal;
private $urlShortened;
/** @var DateTimeImmutable */
private $created_on;
public function __construct(
UrlId $id,
Url $urlOriginal,
Url $urlShortened,
DateTimeImmutable $created_on = null
) {
$this->id = $id;
$this->urlOriginal = $urlOriginal;
$this->urlShortened = $urlShortened;
$this->created_on = $created_on ?? new DateTimeImmutable();
}
/**
* @return UrlId
*/
public function id(): UrlId {
return $this->id;
}
/**
* @return Url
*/
public function urlOriginal(): Url {
return $this->urlOriginal;
}
/**
* @return Url
*/
public function urlShortened(): Url {
return $this->urlShortened;
}
/**
* @return DateTimeImmutable
*/
public function createdOn(): DateTimeImmutable
{
return $this->created_on;
}
/**
* @return string
*/
public function campaign(): ?string
{
return $this->urlOriginal->queryString()['utm_campaign'] ?? null;
}
}