@@ -43,7 +43,7 @@ discard block |
||
43 | 43 | /* Faster to average channels, blend alpha and negate the image here than via filters (tested!) */ |
44 | 44 | $cols = $im -> getImagePixelColor($x, $y); |
45 | 45 | $cols = $cols -> getcolor(); |
46 | - $greyness = (int)(($cols['r'] + $cols['g'] + $cols['b']) / 3) >> 7; // 1 for white, 0 for black |
|
46 | + $greyness = (int) (($cols['r'] + $cols['g'] + $cols['b']) / 3) >> 7; // 1 for white, 0 for black |
|
47 | 47 | $imgData[$y * $imgWidth + $x] = (1 - $greyness); // 1 for black, 0 for white |
48 | 48 | } |
49 | 49 | } |
@@ -214,7 +214,7 @@ discard block |
||
214 | 214 | public static function loadPdf($pdfFile, int $pageWidth = 550) |
215 | 215 | { |
216 | 216 | if (!EscposImage::isImagickLoaded()) { |
217 | - throw new Exception(__FUNCTION__ . " requires imagick extension."); |
|
217 | + throw new Exception(__FUNCTION__." requires imagick extension."); |
|
218 | 218 | } |
219 | 219 | /* |
220 | 220 | * Load first page at very low density (resolution), to figure out what |
@@ -110,7 +110,7 @@ discard block |
||
110 | 110 | */ |
111 | 111 | public function getHeightBytes() |
112 | 112 | { |
113 | - return (int)(($this -> imgHeight + 7) / 8); |
|
113 | + return (int) (($this -> imgHeight + 7) / 8); |
|
114 | 114 | } |
115 | 115 | |
116 | 116 | /** |
@@ -126,7 +126,7 @@ discard block |
||
126 | 126 | */ |
127 | 127 | public function getWidthBytes() |
128 | 128 | { |
129 | - return (int)(($this -> imgWidth + 7) / 8); |
|
129 | + return (int) (($this -> imgWidth + 7) / 8); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | /** |
@@ -282,7 +282,7 @@ discard block |
||
282 | 282 | return $data; |
283 | 283 | } |
284 | 284 | do { |
285 | - $byteVal |= (int)$this -> imgData[$y * $widthPixels + $x] << (7 - $bit); |
|
285 | + $byteVal |= (int) $this -> imgData[$y * $widthPixels + $x] << (7 - $bit); |
|
286 | 286 | $x++; |
287 | 287 | $bit++; |
288 | 288 | if ($x >= $widthPixels) { |
@@ -302,7 +302,7 @@ discard block |
||
302 | 302 | } |
303 | 303 | } while (true); |
304 | 304 | if (strlen($data) != ($this -> getWidthBytes() * $this -> getHeight())) { |
305 | - throw new Exception("Bug in " . __FUNCTION__ . ", wrong number of bytes."); |
|
305 | + throw new Exception("Bug in ".__FUNCTION__.", wrong number of bytes."); |
|
306 | 306 | } |
307 | 307 | return $data; |
308 | 308 | } |
@@ -359,7 +359,7 @@ discard block |
||
359 | 359 | do { |
360 | 360 | $yReal = $y + $yStart; |
361 | 361 | if ($yReal < $heightPixels) { |
362 | - $byteVal |= (int)$this -> imgData[$yReal * $widthPixels + $x] << (7 - $bit); |
|
362 | + $byteVal |= (int) $this -> imgData[$yReal * $widthPixels + $x] << (7 - $bit); |
|
363 | 363 | } |
364 | 364 | $y++; |
365 | 365 | $bit++; |
@@ -380,7 +380,7 @@ discard block |
||
380 | 380 | } |
381 | 381 | } while (true); |
382 | 382 | if (strlen($data) != $widthPixels * $lineHeight) { |
383 | - throw new Exception("Bug in " . __FUNCTION__ . ", wrong number of bytes."); |
|
383 | + throw new Exception("Bug in ".__FUNCTION__.", wrong number of bytes."); |
|
384 | 384 | } |
385 | 385 | return $data; |
386 | 386 | } |
@@ -109,7 +109,7 @@ |
||
109 | 109 | // TODO We can sort into batches of contiguous characters here. |
110 | 110 | foreach ($chars as $char => $glyph) { |
111 | 111 | $verticalBytes = 3; |
112 | - $data = Printer::ESC . "&" . chr($verticalBytes) . chr($char) . chr($char) . chr($glyph -> width) . $glyph -> data; |
|
112 | + $data = Printer::ESC."&".chr($verticalBytes).chr($char).chr($char).chr($glyph -> width).$glyph -> data; |
|
113 | 113 | $this -> printer -> getPrintConnector() -> write($data); |
114 | 114 | } |
115 | 115 | } |
@@ -10,7 +10,7 @@ |
||
10 | 10 | public static function colFormat16(array $in) |
11 | 11 | { |
12 | 12 | // Map 16 x 16 bit unifont (32 bytes) to 16 x 24 ESC/POS column format image (48 bytes). |
13 | - return UnifontGlyphFactory::colFormat8($in, 2, 1) . UnifontGlyphFactory::colFormat8($in, 2, 2); |
|
13 | + return UnifontGlyphFactory::colFormat8($in, 2, 1).UnifontGlyphFactory::colFormat8($in, 2, 2); |
|
14 | 14 | } |
15 | 15 | |
16 | 16 | public static function colFormat8(array $in, $chars = 1, $idx = 1) |
@@ -43,7 +43,7 @@ |
||
43 | 43 | { |
44 | 44 | if (!$this -> started) { |
45 | 45 | $mode = Printer::MODE_FONT_B | Printer::MODE_DOUBLE_HEIGHT | Printer::MODE_DOUBLE_WIDTH; |
46 | - $this -> printer -> getPrintConnector() -> write(Printer::ESC . "!" . chr($mode)); |
|
46 | + $this -> printer -> getPrintConnector() -> write(Printer::ESC."!".chr($mode)); |
|
47 | 47 | $this -> printer -> selectUserDefinedCharacterSet(true); |
48 | 48 | } |
49 | 49 | // Normalize text - this replaces combining characters with composed glyphs, and also helps us eliminated bad UTF-8 early |
@@ -46,15 +46,15 @@ discard block |
||
46 | 46 | { |
47 | 47 | $valid = $this->getLocalPrinters(); |
48 | 48 | if (count($valid) == 0) { |
49 | - throw new BadMethodCallException("You do not have any printers installed on " . |
|
49 | + throw new BadMethodCallException("You do not have any printers installed on ". |
|
50 | 50 | "this system via CUPS. Check 'lpr -a'."); |
51 | 51 | } |
52 | 52 | |
53 | 53 | if (array_search($dest, $valid, true) === false) { |
54 | - throw new BadMethodCallException("'$dest' is not a printer on this system. " . |
|
55 | - "Printers are: [" . implode(", ", $valid) . "]"); |
|
54 | + throw new BadMethodCallException("'$dest' is not a printer on this system. ". |
|
55 | + "Printers are: [".implode(", ", $valid)."]"); |
|
56 | 56 | } |
57 | - $this->buffer = array (); |
|
57 | + $this->buffer = array(); |
|
58 | 58 | $this->printerName = $dest; |
59 | 59 | } |
60 | 60 | |
@@ -105,18 +105,18 @@ discard block |
||
105 | 105 | */ |
106 | 106 | protected function getCmdOutput($cmd) |
107 | 107 | { |
108 | - $descriptors = array ( |
|
109 | - 1 => array ( |
|
108 | + $descriptors = array( |
|
109 | + 1 => array( |
|
110 | 110 | "pipe", |
111 | 111 | "w" |
112 | 112 | ), |
113 | - 2 => array ( |
|
113 | + 2 => array( |
|
114 | 114 | "pipe", |
115 | 115 | "w" |
116 | 116 | ) |
117 | 117 | ); |
118 | 118 | $process = proc_open($cmd, $descriptors, $fd); |
119 | - if (! is_resource($process)) { |
|
119 | + if (!is_resource($process)) { |
|
120 | 120 | throw new Exception("Command '$cmd' failed to start."); |
121 | 121 | } |
122 | 122 | /* Read stdout */ |
@@ -53,7 +53,7 @@ |
||
53 | 53 | public function finalize() |
54 | 54 | { |
55 | 55 | ob_end_clean(); |
56 | - echo "intent:base64," . base64_encode($this->getData()) . "#Intent;scheme=rawbt;package=ru.a402d.rawbtprinter;end;"; |
|
56 | + echo "intent:base64,".base64_encode($this->getData())."#Intent;scheme=rawbt;package=ru.a402d.rawbtprinter;end;"; |
|
57 | 57 | $this->buffer = null; |
58 | 58 | } |
59 | 59 |
@@ -35,7 +35,7 @@ |
||
35 | 35 | |
36 | 36 | $this -> fp = @fsockopen($ip, $port, $errno, $errstr, $timeout); |
37 | 37 | if ($this -> fp === false) { |
38 | - throw new Exception("Cannot initialise NetworkPrintConnector: " . $errstr); |
|
38 | + throw new Exception("Cannot initialise NetworkPrintConnector: ".$errstr); |
|
39 | 39 | } |
40 | 40 | } |
41 | 41 | } |
@@ -117,7 +117,7 @@ discard block |
||
117 | 117 | if (preg_match(self::REGEX_LOCAL, $dest) == 1) { |
118 | 118 | // Straight to LPT1, COM1 or other local port. Allowed only if we are actually on windows. |
119 | 119 | if ($this -> platform !== self::PLATFORM_WIN) { |
120 | - throw new BadMethodCallException("WindowsPrintConnector can only be " . |
|
120 | + throw new BadMethodCallException("WindowsPrintConnector can only be ". |
|
121 | 121 | "used to print to a local printer ('".$dest."') on a Windows computer."); |
122 | 122 | } |
123 | 123 | $this -> isLocal = true; |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | $this -> hostname = $hostname; |
153 | 153 | $this -> printerName = $dest; |
154 | 154 | } else { |
155 | - throw new BadMethodCallException("Printer '" . $dest . "' is not a valid " . |
|
155 | + throw new BadMethodCallException("Printer '".$dest."' is not a valid ". |
|
156 | 156 | "printer name. Use local port (LPT1, COM1, etc) or smb://computer/printer notation."); |
157 | 157 | } |
158 | 158 | $this -> buffer = []; |
@@ -187,9 +187,9 @@ discard block |
||
187 | 187 | protected function finalizeLinux($data) |
188 | 188 | { |
189 | 189 | /* Non-Windows samba printing */ |
190 | - $device = "//" . $this -> hostname . "/" . $this -> printerName; |
|
190 | + $device = "//".$this -> hostname."/".$this -> printerName; |
|
191 | 191 | if ($this -> userName !== null) { |
192 | - $user = ($this -> workgroup != null ? ($this -> workgroup . "\\") : "") . $this -> userName; |
|
192 | + $user = ($this -> workgroup != null ? ($this -> workgroup."\\") : "").$this -> userName; |
|
193 | 193 | if ($this -> userPassword == null) { |
194 | 194 | // No password |
195 | 195 | $command = sprintf( |
@@ -227,8 +227,8 @@ discard block |
||
227 | 227 | } |
228 | 228 | $retval = $this -> runCommand($command, $outputStr, $errorStr, $data); |
229 | 229 | if ($retval != 0) { |
230 | - throw new Exception("Failed to print. Command \"$redactedCommand\" " . |
|
231 | - "failed with exit code $retval: " . trim($errorStr) . trim($outputStr)); |
|
230 | + throw new Exception("Failed to print. Command \"$redactedCommand\" ". |
|
231 | + "failed with exit code $retval: ".trim($errorStr).trim($outputStr)); |
|
232 | 232 | } |
233 | 233 | } |
234 | 234 | |
@@ -253,10 +253,10 @@ discard block |
||
253 | 253 | /* Windows-friendly printing of all sorts */ |
254 | 254 | if (!$this -> isLocal) { |
255 | 255 | /* Networked printing */ |
256 | - $device = "\\\\" . $this -> hostname . "\\" . $this -> printerName; |
|
256 | + $device = "\\\\".$this -> hostname."\\".$this -> printerName; |
|
257 | 257 | if ($this -> userName !== null) { |
258 | 258 | /* Log in */ |
259 | - $user = "/user:" . ($this -> workgroup != null ? ($this -> workgroup . "\\") : "") . $this -> userName; |
|
259 | + $user = "/user:".($this -> workgroup != null ? ($this -> workgroup."\\") : "").$this -> userName; |
|
260 | 260 | if ($this -> userPassword == null) { |
261 | 261 | $command = sprintf( |
262 | 262 | "net use %s %s", |
@@ -280,8 +280,8 @@ discard block |
||
280 | 280 | } |
281 | 281 | $retval = $this -> runCommand($command, $outputStr, $errorStr); |
282 | 282 | if ($retval != 0) { |
283 | - throw new Exception("Failed to print. Command \"$redactedCommand\" " . |
|
284 | - "failed with exit code $retval: " . trim($errorStr)); |
|
283 | + throw new Exception("Failed to print. Command \"$redactedCommand\" ". |
|
284 | + "failed with exit code $retval: ".trim($errorStr)); |
|
285 | 285 | } |
286 | 286 | } |
287 | 287 | /* Final print-out */ |
@@ -297,7 +297,7 @@ discard block |
||
297 | 297 | } else { |
298 | 298 | /* Drop data straight on the printer */ |
299 | 299 | if (!$this -> runWrite($data, $this -> printerName)) { |
300 | - throw new Exception("Failed to write file to printer at " . $this -> printerName); |
|
300 | + throw new Exception("Failed to write file to printer at ".$this -> printerName); |
|
301 | 301 | } |
302 | 302 | } |
303 | 303 | } |