Printer.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. namespace WhichBrowser\Analyser\Header\Useragent\Device;
  3. use WhichBrowser\Constants;
  4. trait Printer
  5. {
  6. private function detectPrinter($ua)
  7. {
  8. if (!preg_match('/(TASKalfa|CanonIJCL|PrintSmart)/ui', $ua)) {
  9. return;
  10. }
  11. /* TASKalfa */
  12. if (preg_match('/TASKalfa ([0-9A-Z]+)/iu', $ua, $match)) {
  13. $this->data->device->setIdentification([
  14. 'manufacturer' => 'Kyocera',
  15. 'model' => 'TASKalfa ' . $match[1],
  16. 'type' => Constants\DeviceType::PRINTER
  17. ]);
  18. }
  19. /* Canon IJ */
  20. if (preg_match('/CanonIJCL/iu', $ua, $match)) {
  21. $this->data->device->setIdentification([
  22. 'manufacturer' => 'Canon',
  23. 'model' => 'IJ Printer',
  24. 'type' => Constants\DeviceType::PRINTER
  25. ]);
  26. }
  27. /* HP Web PrintSmart */
  28. if (preg_match('/HP Web PrintSmart/iu', $ua, $match)) {
  29. $this->data->device->setIdentification([
  30. 'manufacturer' => 'HP',
  31. 'model' => 'Web PrintSmart',
  32. 'type' => Constants\DeviceType::PRINTER
  33. ]);
  34. }
  35. }
  36. }