Completed
Push — master ( 06db8f...7dd0ed )
by Francimar
04:19
created

Diebold   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 1
dl 0
loc 24
ccs 10
cts 10
cp 1
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A drawer() 0 16 2
1
<?php
2
3
namespace Thermal\Profile;
4
5
use Thermal\Printer;
6
7
class Diebold extends Elgin
8
{
9
    /**
10
     * @param int $number drawer id
11
     * @param int $on_time time in milliseconds that activate the drawer
12
     * @param int $off_time time in milliseconds that deactivate the drawer
13
     */
14 1
    public function drawer($number, $on_time, $off_time)
15
    {
16
        $index = [
17 1
            Printer::DRAWER_1 => '0'
18
        ];
19 1
        if (!isset($index[$number])) {
20 1
            throw new \Exception(
21 1
                sprintf('Drawer %d not available for printer "%s"', $this->getName(), intval($number)),
22 1
                404
23
            );
24
        }
25 1
        $on_time = min((int)($on_time / 2), 65);
26 1
        $off_time = min((int)($off_time / 2), 65);
27 1
        $this->getConnection()->write("\e&" . $index[$number] . chr($on_time) . chr($off_time));
28 1
        return $this;
29
    }
30
}
31