Sid::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
c 1
b 0
f 0
dl 0
loc 10
rs 10
cc 2
nc 2
nop 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Skrill\ValueObject;
6
7
use DateTimeImmutable;
8
use Skrill\Exception\InvalidSidException;
9
use Skrill\ValueObject\Traits\ValueToStringTrait;
10
11
/**
12
 * Value object for sid.
13
 */
14
final class Sid
15
{
16
    use ValueToStringTrait;
17
18
    /**
19
     * @var DateTimeImmutable
20
     */
21
    private $expirationTillDateTime;
22
23
    /**
24
     * @param string            $value
25
     * @param DateTimeImmutable $expirationTillDateTime
26
     *
27
     * @throws InvalidSidException
28
     */
29
    public function __construct(string $value, DateTimeImmutable $expirationTillDateTime)
30
    {
31
        $value = trim($value);
32
33
        if (empty($value)) {
34
            throw InvalidSidException::emptySid();
35
        }
36
37
        $this->value = $value;
38
        $this->expirationTillDateTime = $expirationTillDateTime;
39
    }
40
41
    /**
42
     * @return DateTimeImmutable
43
     */
44
    public function getExpirationTillDateTime(): DateTimeImmutable
45
    {
46
        return $this->expirationTillDateTime;
47
    }
48
}
49