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

Page   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 50
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 1
A getIndirectReference() 0 4 1
A writeToStream() 0 4 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;
11
12
use Bacon\Pdf\Object\AbstractObject;
13
use Bacon\Pdf\Object\DictionaryObject;
14
use Bacon\Pdf\Object\IndirectObject;
15
use Bacon\Pdf\Object\NameObject;
16
use Bacon\Pdf\Object\NullObject;
17
use SplFileObject;
18
19
class Page extends AbstractObject
20
{
21
    /**
22
     * @var Document
23
     */
24
    private $document;
25
26
    /**
27
     * @var IndirectObject
28
     */
29
    private $indirectReference;
30
31
    /**
32
     * @var DictionaryObject
33
     */
34
    private $dictionary;
35
36
    /**
37
     * @param Document $document
38
     * @param int      $width
39
     * @param int      $height
40
     */
41
    public function __construct(Document $document, IndirectObject $indirectReference, $width, $height)
42
    {
43
        $this->document = $document;
44
        $this->indirectReference = $indirectReference;
45
46
        $this->dictionary = new DictionaryObject();
47
        $this->dictionary['Type'] = new NameObject('Page');
48
        $this->dictionary['Parent'] = new NullObject();
49
        $this->dictionary['Resources'] = new DictionaryObject();
50
        $this->dictionary['MediaBox'] = new RectangleObject(0, 0, $width, $height);
51
    }
52
53
    /**
54
     * @return IndirectObject
55
     */
56
    public function getIndirectReference()
57
    {
58
        return $this->indirectReference;
59
    }
60
61
    /**
62
     * {@inheritdoc}
63
     */
64
    public function writeToStream(SplFileObject $fileObject, $encryptionKey)
65
    {
66
        $this->dictionary->writeToStream($fileObject, $encryptionKey);
67
    }
68
}
69