BorderedElement::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 2
Bugs 1 Features 1
Metric Value
c 2
b 1
f 1
dl 0
loc 6
ccs 3
cts 3
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
crap 1
1
<?php
2
3
namespace Matks\Vivian\Output;
4
5
use Matks\Vivian\Border\Border;
6
use Matks\Vivian\Border\BorderManager;
7
8
/**
9
 * Bordered Element
10
 *
11
 * String to be echoed with a border to draw
12
 */
13
class BorderedElement extends TextElement
14
{
15
16
    /**
17
     * @var Border
18
     */
19
    private $border;
20
21
    /**
22
     * @param string $text
23
     * @param Border $border
24
     */
25
    public function __construct($text, Border $border)
26
    {
27 1
        parent::__construct($text);
28
29 1
        $this->border = $border;
30 1
    }
31
32
    /**
33
     * @return Border
34
     */
35
    public function getBorder()
36
    {
37 1
        return $this->border;
38
    }
39
40
    /**
41
     * Render bordered element
42
     *
43
     * @return string
44
     */
45
    public function render()
46
    {
47 1
        $text         = parent::render();
48 1
        $borderedText = BorderManager::buildBorder($text, $this->border);
49
50 1
        return $borderedText;
51
    }
52
}
53