Text::render()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 7
rs 9.4285
cc 2
eloc 5
nc 2
nop 0
1
<?php
2
namespace Sign;
3
4
class Text {
5
    private $_text;
6
    private $_colour;
7
    private $_background;
8
    private $_map = array(
0 ignored issues
show
Unused Code introduced by
The property $_map is not used and could be removed.

This check marks private properties in classes that are never used. Those properties can be removed.

Loading history...
9
    );
10
11
    public function __construct($text, $colour = 'red', $background = 'black') {
12
        $this->_text = $text;
13
        $this->_colour = $colour;
14
        $this->_background = $background;
15
    }
16
17
    private function _colour() {
18
        return ColourMap::get($this->_colour, $this->_background);
19
    }
20
21
    public function render() {
22
        $output = '';
23
        foreach (str_split($this->_text) as $char) {
24
            $output .= $this->_colour().dechex(ord($char));
25
        }
26
        return $output;
27
    }
28
29
    public function length() {
30
        return strlen($this->_text);
31
    }
32
}
33