Completed
Pull Request — master (#86)
by Vladimir
02:53
created

CompilerPostRenderTrait::setCompiledOutput()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2.1481

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 4
cts 6
cp 0.6667
rs 9.9
c 0
b 0
f 0
cc 2
nc 2
nop 1
crap 2.1481
1
<?php
2
3
/**
4
 * @copyright 2018 Vladimir Jimenez
5
 * @license   https://github.com/stakx-io/stakx/blob/master/LICENSE.md MIT
6
 */
7
8
namespace allejo\stakx\Event;
9
10
use allejo\stakx\Utilities\StrUtils;
11
12
trait CompilerPostRenderTrait
13
{
14
    /** @var string */
15
    protected $compiledOutput;
16
17 13
    public function getCompiledOutput()
18
    {
19 13
        return (string)$this->compiledOutput;
20
    }
21
22
    /**
23
     * Modify the compiled output.
24
     *
25
     * @param string $compiledOutput
26
     */
27 1
    public function setCompiledOutput($compiledOutput)
28
    {
29 1
        if (!StrUtils::canBeCastedToString($compiledOutput))
30
        {
31
            @trigger_error('CompileProcessPostRenderPageView :: Value cannot be set to something that cannot be cast into a string.', E_USER_WARNING);
0 ignored issues
show
Security Best Practice introduced by
It seems like you do not handle an error condition here. This can introduce security issues, and is generally not recommended.

If you suppress an error, we recommend checking for the error condition explicitly:

// For example instead of
@mkdir($dir);

// Better use
if (@mkdir($dir) === false) {
    throw new \RuntimeException('The directory '.$dir.' could not be created.');
}
Loading history...
32
33
            return;
34
        }
35
36 1
        $this->compiledOutput = $compiledOutput;
37 1
    }
38
}
39