RenderAwareMethods   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 34
ccs 5
cts 5
cp 1
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A render() 0 5 1
A __toString() 0 4 1
getRenderer() 0 1 ?
1
<?php
2
3
/**
4
 * This file is part of slick/form package
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
namespace Slick\Form\Element;
11
12
use Slick\Form\Renderer\RendererInterface;
13
14
/**
15
 * Render capabilities for HTML elements
16
 *
17
 * @package Slick\Form\Element
18
 * @author  Filipe Silva <[email protected]>
19
 */
20
trait RenderAwareMethods
21
{
22
23
    /**
24
     * Returns the HTML string for current element
25
     *
26
     * @param array $context
27
     *
28
     * @return string
29
     */
30 20
    public function render($context = [])
31
    {
32 20
        $this->getRenderer()->setElement($this);
33 20
        return $this->getRenderer()->render($context);
34
    }
35
36
    /**
37
     * Returns the HTML string for this element
38
     *
39
     * @return string
40
     */
41 16
    public function __toString()
42
    {
43 16
        return (string) $this->render();
44
    }
45
46
    /**
47
     * Gets the HTML renderer for this element
48
     *
49
     * @return RendererInterface
50
     */
51
    abstract protected function getRenderer();
52
53
}