Completed
Push — master ( a05270...10fb5b )
by Ben
02:15
created

DateType::writeToStream()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
rs 9.4286
cc 1
eloc 4
nc 1
nop 2
1
<?php
2
/**
3
 * BaconPdf
4
 *
5
 * @link      http://github.com/Bacon/BaconPdf For the canonical source repository
6
 * @copyright 2015 Ben 'DASPRiD' Scholzen
7
 * @license   http://opensource.org/licenses/BSD-2-Clause Simplified BSD License
8
 */
9
10
namespace Bacon\Pdf\Type;
11
12
use DateTimeImmutable;
13
use SplFileObject;
14
15
/**
16
 * Date type as defined by section 3.8.3
17
 */
18
class DateType extends AbstractObject
19
{
20
    /**
21
     * @var DateTimeImmutable
22
     */
23
    private $dateTime;
24
25
    /**
26
     * @param DateTimeImmutable $dateTime
27
     */
28
    public function __construct(DateTimeImmutable $dateTime)
29
    {
30
        $this->dateTime = $dateTime;
31
    }
32
33
    /**
34
     * @return DateTimeImmutable
35
     */
36
    public function getDateTime()
37
    {
38
        return $this->dateTime;
39
    }
40
41
    /**
42
     * {@inheritdoc}
43
     */
44
    public function writeToStream(SplFileObject $fileObject, $encryptionKey)
45
    {
46
        (new LiteralStringObject(
47
            substr_replace($this->dateTime->format('\D\:YmdHisO'), "'", -2, 0) . "'"
48
        ))->writeToStream($fileObject, $encryptionKey);
49
    }
50
}
51