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

HexadecimalStringObject   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A getValue() 0 4 1
A writeToStream() 0 12 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\Object;
11
12
/**
13
 * Hexadecimal string object as defined by section 3.2.3
14
 */
15
class HexadecimalStringObject extends AbstractObject
16
{
17
    /**
18
     * @var string
19
     */
20
    private $value;
21
22
    /**
23
     * @param string $value
24
     */
25
    public function __construct($value)
26
    {
27
        $this->value = $value;
28
    }
29
30
    /**
31
     * @return string
32
     */
33
    public function getValue()
34
    {
35
        return $this->value;
36
    }
37
38
    /**
39
     * {@inheritdoc}
40
     */
41
    public function writeToStream(SplFileObject $fileObject, $encryptionKey)
42
    {
43
        $value = $this->value;
44
45
        if (null !== $encryptionKey) {
46
            $value = \Bacon\Pdf\Utils\EncryptionUtils::rc4($encryptionKey, $value);
47
        }
48
49
        $fileObject->fwrite('<');
50
        $fileObject->fwrite(chunk_split(bin2hex($value), 255, "\n"));
51
        $fileObject->fwrite('>');
52
    }
53
}
54