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

DateType   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getDateTime() 0 4 1
A writeToStream() 0 6 1
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