Sign::upload()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
c 2
b 0
f 0
dl 0
loc 9
rs 9.6666
cc 2
eloc 6
nc 2
nop 0
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