Completed
Push — master ( 655053...db47c8 )
by Ben
02:17
created

IndirectObject::readFromStream()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
eloc 1
nc 1
nop 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\Object;
11
12
use Bacon\Pdf\Exception\PdfReadException;
13
use SplFileObject;
14
15
/**
16
 * Indirect object as defined by section 3.2.9
17
 */
18
class IndirectObject implements ObjectInterface
19
{
20
    /**
21
     * @var int
22
     */
23
    protected $id;
24
25
    /**
26
     * @var int
27
     */
28
    protected $generation;
29
30
    /**
31
     * @var ObjectStorage
32
     */
33
    protected $objectStorage;
34
35
    /**
36
     * @param int           $id
37
     * @param int           $generation
38
     * @param ObjectStorage $objectStorage
39
     */
40
    public function __construct($id, $generation, ObjectStorage $objectStorage)
41
    {
42
        $this->id            = $id;
43
        $this->generation    = $generation;
44
        $this->objectStorage = $objectStorage;
45
    }
46
47
    /**
48
     * @return int
49
     */
50
    public function getId()
51
    {
52
        return $this->id;
53
    }
54
55
    /**
56
     * @return int
57
     */
58
    public function getGeneration()
59
    {
60
        return $this->generation;
61
    }
62
63
    /**
64
     * @return ObjectStorage
65
     */
66
    public function getObjectStorage()
67
    {
68
        return $this->objectStorage;
69
    }
70
71
    /**
72
     * {@inheritdoc}
73
     */
74
    public function getObject()
75
    {
76
        return $this->objectStorage->getObject($this)->getObject();
77
    }
78
79
    /**
80
     * {@inheritdoc}
81
     */
82
    public function writeToStream(SplFileObject $fileObject, $encryptionKey)
83
    {
84
        $fileObject->fwrite(sprintf('%d %d R', $this->id, $this->generation));
85
    }
86
}
87