Completed
Pull Request — master (#86)
by Vladimir
08:24
created

CompilerPostRenderTrait   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 1
dl 0
loc 27
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getCompiledOutput() 0 4 1
A setCompiledOutput() 0 11 2
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
    public function getCompiledOutput()
18
    {
19
        return (string)$this->compiledOutput;
20
    }
21
22
    /**
23
     * Modify the compiled output.
24
     *
25
     * @param string $compiledOutput
26
     */
27
    public function setCompiledOutput($compiledOutput)
28
    {
29
        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
        $this->compiledOutput = $compiledOutput;
37
    }
38
}
39