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

TextStringType::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 Bacon\Pdf\Object\AbstractObject;
13
use Bacon\Pdf\Object\LiteralStringObject;
14
use SplFileObject;
15
16
/**
17
 * Text string type as defined by section 3.8.1
18
 */
19
class TextStringType extends AbstractObject
20
{
21
    /**
22
     * @var string
23
     */
24
    private $value;
25
26
    /**
27
     * @param string $value
28
     */
29
    public function __construct($value)
30
    {
31
        $this->value = $value;
32
    }
33
34
    /**
35
     * {@inheritdoc}
36
     */
37
    public function writeToStream(SplFileObject $fileObject, $encryptionKey)
38
    {
39
        (new LiteralStringObject(
40
            "\xfe\xff" . iconv('UTF-8', 'UTF-16BE', $this->value)
41
        ))->writeToStream($fileObject, $encryptionKey);
0 ignored issues
show
Documentation introduced by
$fileObject is of type object<SplFileObject>, but the function expects a object<Bacon\Pdf\Object\SplFileObject>.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
42
    }
43
}
44