Test Setup Failed
Push — master ( 01683c...feea73 )
by Vitaliy
03:11
created

Expiration::notStore()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the AppleApnPush package
7
 *
8
 * (c) Vitaliy Zhuk <[email protected]>
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code
12
 */
13
14
namespace Apple\ApnPush\Model;
15
16
/**
17
 * Expiration of notification
18
 */
19
class Expiration
20
{
21
    /**
22
     * @var \DateTime
23
     */
24
    private $storeTo;
25
26
    /**
27
     * Constructor.
28
     *
29
     * @param \DateTime $availableTo
30
     */
31
    public function __construct(\DateTime $availableTo = null)
32
    {
33
        if ($availableTo) {
34
            $this->storeTo = clone $availableTo;
35
            $this->storeTo->setTimezone(new \DateTimeZone('UTC'));
36
        }
37
    }
38
39
    /**
40
     * Get value
41
     *
42
     * @return int
43
     *
44
     * @throws \LogicException
45
     */
46
    public function getValue(): int
47
    {
48
        if (!$this->storeTo) {
49
            return 0;
50
        }
51
52
        return (int) $this->storeTo->format('U');
53
    }
54
}
55