Sid   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 9
c 1
b 0
f 0
dl 0
loc 33
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getExpirationTillDateTime() 0 3 1
A __construct() 0 10 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