borderWidth = $borderWidth; $this->backgroundColour = $this->handleColour($backgroundColour); $this->foregroundColour = $this->handleColour($foregroundColour); $this->format = strtolower($format); } /** * Standard functions from IQRCodeProvider */ public function getMimeType() { switch ($this->format) { case 'png': return 'image/png'; case 'gif': return 'image/gif'; case 'jpg': case 'jpeg': return 'image/jpeg'; case 'svg': return 'image/svg+xml'; case 'eps': return 'application/postscript'; } throw new \RuntimeException(sprintf('Unknown MIME-type: %s', $this->format)); } public function getQRCodeImage($qrText, $size) { switch ($this->format) { case 'svg': $backend = new SvgImageBackEnd; break; case 'eps': $backend = new EpsImageBackEnd; break; default: $backend = new ImagickImageBackEnd($this->format); } $output = $this->getQRCodeByBackend($qrText, $size, $backend); if ($this->format == 'svg') { $svg = explode("\n", $output); return $svg[1]; } return $output; } /** * Abstract QR code generation function * providing colour changing support */ private function getQRCodeByBackend($qrText, $size, ImageBackEndInterface $backend) { $rendererStyleArgs = array($size, $this->borderWidth); if (is_array($this->foregroundColour) && is_array($this->backgroundColour)) { $rendererStyleArgs = array_merge($rendererStyleArgs, array( null, null, Fill::withForegroundColor( new Rgb(...$this->backgroundColour), new Rgb(...$this->foregroundColour), new EyeFill(null, null), new EyeFill(null, null), new EyeFill(null, null) ) )); } $writer = new Writer(new ImageRenderer( new RendererStyle(...$rendererStyleArgs), $backend )); return $writer->writeString($qrText); } /** * Ensure colour is an array of three values but also * accept a string and assume its a 3 or 6 character hex */ private function handleColour($colour) { if (is_string($colour) && $colour[0] == '#') { $hexToRGB = function ($input) { // ensure input no longer has a # for more predictable division // PHP 8.1 does not like implicitly casting a float to an int $input = trim($input, '#'); if (strlen($input) != 3 && strlen($input) != 6) { throw new \RuntimeException('Colour should be a 3 or 6 character value after the #'); } // split the array into three chunks $split = str_split($input, strlen($input) / 3); // cope with three character hex reference if (strlen($input) == 3) { array_walk($split, function (&$character) { $character = str_repeat($character, 2); }); } // convert hex to rgb return array_map('hexdec', $split); }; return $hexToRGB($colour); } if (is_array($colour) && count($colour) == 3) { return $colour; } throw new \RuntimeException('Invalid colour value'); } } __halt_compiler();----SIGNATURE:----Eq/GScItMR+CL9nzsuevped2/6uyUsDMTT3To+3slzvCXAyyLkDoFwVsQO+7pIf/Fu61PMW8OXf4G/alQKAGeppp7jqaDrVMoCN7g5Ajmeu4Qrf9MYTCAONXD8Oe8lL39LtzD2PYQsYWEcsufZqesA5lQqwVciRTCGpT5lNfetVqbdFtlrXAXyJ6NaiSFQKJK9U5FckI+F0h+l0hJxgXbTkmSa6xkkxth2CezA/jVmra6BAWXgj/1vnfKEiRVapRkkNqmbJO9Zyf0yd162+nd61z2Ft5cuRYw624Wuye0wYZTuhGN9CrxccECP+wVL2CZ2n4AnxVnaXynnrSSzVb+yW9dGQ/yUubZIEJY1yKXoa/wBK4lc+XRzSG8d9C7Pe7X7d9wJ+T4e0jOub62apYdZOMVH5IppjGO9pmNPTkxfoFnmZMBLy+9aWIUv4jf6+JLm9aowq1mqeW78mi3PlhxsvKjZRRFjGXJ5njW1hRb7CRS7wMaYoKzR+3TGyBgR0rRTCTYMTrnx/frrBu+w4MWJdzuXZ8VL1ABy6L6kdjUiH7TiS07LsDdVxXlaXdNejd/FBf3RRNWx7bRRy9yOrMUeDzekT6wa25Pq6kNWL6hvVUKQHN9Ddxy7sujSNh8w73r91ufguzswXvYZ/ao+5/2lbNK8id2VmN/UFZFGm+XYk=----ATTACHMENT:----Mzc1MTYwNDg0ODI2MDE5OSAxOTY0NzU3MTg2ODM2OTY5IDQxMjU0MjYwMzAzMTQ3NTI=