CanRenderTrait::__toString()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
ccs 0
cts 2
cp 0
crap 2
rs 10
c 1
b 0
f 1
1
<?php
2
3
namespace ByTIC\Assets\Assets\Asset\Traits;
4
5
use ByTIC\Assets\Assets\Asset\AssetRenderer;
6
7
/**
8
 * Trait CanRenderTrait
9
 * @package ByTIC\Assets\Assets\Asset\Traits
10
 */
11
trait CanRenderTrait
12
{
13
    protected $output = null;
14
15
    /**
16
     * @return string
17
     */
18
    public function __toString()
19
    {
20
        return $this->render();
21
    }
22
23
    /**
24
     * @return string
25
     */
26 1
    public function output()
27
    {
28 1
        if ($this->output === null) {
29 1
            $this->output = $this->render();
30
        }
31
32 1
        return $this->output;
33
    }
34
35
    /**
36
     * @return string
37
     */
38 1
    protected function render()
39
    {
40 1
        return AssetRenderer::for($this);
41
    }
42
}
43