Sign   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 3
Bugs 0 Features 0
Metric Value
wmc 6
c 3
b 0
f 0
lcom 1
cbo 1
dl 0
loc 34
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A _hex2bin() 0 15 3
A upload() 0 9 2
A addLine() 0 5 1
1
<?php
2
namespace Sign;
3
4
class Sign {
5
    private $_lines = array();
6
    private function _hex2bin($hexstr)
7
    {
8
        $n = strlen($hexstr);
9
        $sbin="";
10
        $i=0;
11
        while($i<$n)
12
        {
13
            $a =substr($hexstr,$i,2);
14
            $c = pack("H*",$a);
15
            if ($i==0){$sbin=$c;}
16
            else {$sbin.=$c;}
17
            $i+=2;
18
        }
19
        return $sbin;
20
    }
21
22
    public function upload() {
23
        $output = '99010102AB00010501';
24
        foreach ($this->_lines as $line) {
25
            $output .= $line->render();
26
        }
27
        $output .= '329900';
28
        //return $output;
29
        return $this->_hex2bin($output);
30
    }
31
32
    public function addLine($text) {
33
        $line = new Line($text, $this);
34
        $this->_lines[] = $line;
35
        return $line;
36
    }
37
}
38