Conditions | 5 |
Paths | 6 |
Total Lines | 33 |
Code Lines | 18 |
Lines | 0 |
Ratio | 0 % |
Tests | 0 |
CRAP Score | 30 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
21 | public function translate(InternalImage $command): iterable |
||
22 | { |
||
23 | if (\preg_match('~\.bmp$~i', $command->getName())) { |
||
24 | $instruction = \vsprintf('PUTBMP %d,%d,"%s"', [ |
||
25 | $command->getX(), |
||
26 | $command->getY(), |
||
27 | $command->getName(), |
||
28 | ]); |
||
29 | |||
30 | if ($command->getBpp()) { |
||
31 | $instruction .= ','.$command->getBpp(); |
||
32 | } |
||
33 | |||
34 | if ($command->getContrast()) { |
||
35 | $instruction .= ','.$command->getContrast(); |
||
36 | } |
||
37 | |||
38 | yield $instruction; |
||
39 | |||
40 | return; |
||
41 | } |
||
42 | |||
43 | if (\preg_match('~\.pcx$~i', $command->getName())) { |
||
44 | yield \vsprintf('PUTPCX %d,%d,"%s"', [ |
||
45 | $command->getX(), |
||
46 | $command->getY(), |
||
47 | $command->getName(), |
||
48 | ]); |
||
49 | |||
50 | return; |
||
51 | } |
||
52 | |||
53 | throw new \InvalidArgumentException(); |
||
54 | } |
||
56 |