Text::length()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 3
rs 10
cc 1
eloc 2
nc 1
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