Passed
Push — master ( 10cd5c...92ee40 )
by Jhao
02:18
created

TrackingEventOperationParameters::getPerformedAt()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 5
ccs 2
cts 2
cp 1
crap 1
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * This file is part of RussianPost SDK package.
5
 *
6
 * © Appwilio (http://appwilio.com), greabock (https://github.com/greabock), JhaoDa (https://github.com/jhaoda)
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
declare(strict_types=1);
13
14
namespace Appwilio\RussianPostSDK\Tracking\Single;
15
16
final class TrackingEventOperationParameters
17
{
18
    /** @var Parameter */
19
    private $OperType;
20
21
    /** @var Parameter */
22
    private $OperAttr;
23
24
    /** @var string */
25
    private $OperDate;
26
27
    /**
28
     * Код операции (OperType→Id).
29
     *
30
     * @link https://tracking.pochta.ru/support/dictionaries/operation_codes
31
     *
32
     * @return int
33
     */
34 1
    public function getOperationId(): int
35
    {
36 1
        return $this->OperType->getId();
37
    }
38
39
    /**
40
     * Название операции (OperType→Name).
41
     *
42
     * @link https://tracking.pochta.ru/support/dictionaries/operation_codes
43
     *
44
     * @return string
45
     */
46 1
    public function getOperationName(): string
47
    {
48 1
        return $this->OperType->getName();
49
    }
50
51
    /**
52
     * Код атрибута операции (OperAttr→Id).
53
     *
54
     * @link https://tracking.pochta.ru/support/dictionaries/operation_codes
55
     *
56
     * @return int
57
     */
58 1
    public function getAttributeId(): int
59
    {
60 1
        return $this->OperAttr->getId();
61
    }
62
63
    /**
64
     * Название атрибута операции (OperAttr→Name).
65
     *
66
     * @link https://tracking.pochta.ru/support/dictionaries/operation_codes
67
     *
68
     * @return string
69
     */
70 1
    public function getAttributeName(): string
71
    {
72 1
        return $this->OperAttr->getName();
73
    }
74
75
    /**
76
     * Время проведения операции (OperDate).
77
     *
78
     * @return \DateTimeImmutable
79
     */
80 1
    public function getPerformedAt(): \DateTimeImmutable
81
    {
82
        // Использовать \DATE_RFC3339_EXTENDED можно только в PHP 7.3+
83
        // @see https://bugs.php.net/bug.php?id=76009
84 1
        return \DateTimeImmutable::createFromFormat('Y-m-d\TH:i:s.???P', $this->OperDate);
85
    }
86
}
87