diff --git a/examples/printers.php b/examples/printers.php new file mode 100644 index 0000000..db16e1e --- /dev/null +++ b/examples/printers.php @@ -0,0 +1,12 @@ +$meta) { + printf("%s\n%s\n\n", $printer, json_encode($meta,JSON_PRETTY_PRINT)); +} + diff --git a/src/PrinterList.php b/src/PrinterList.php new file mode 100644 index 0000000..607fb32 --- /dev/null +++ b/src/PrinterList.php @@ -0,0 +1,49 @@ + $name, + 'description' => array_shift($meta), + ]; + foreach ($meta as $prop) { + if (strpos($prop, "=") === false) continue; + list($key,$value) = explode("=",$prop,2); + $props[$key] = $value; + } + self::$printers[$name] = $props; + } + } + } + + public function getIterator() + { + if (empty(self::$printers)) self::update(); + return new ArrayIterator(self::$printers); + } + + public function getPrinterNames() + { + if (empty(self::$printers)) self::update(); + return array_keys(self::$printers); + } +} \ No newline at end of file