Puffin.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. namespace WhichBrowser\Analyser\Header;
  3. use WhichBrowser\Data;
  4. class Puffin
  5. {
  6. public function __construct($header, &$data)
  7. {
  8. $this->data =& $data;
  9. $parts = explode('/', $header);
  10. if ($this->data->browser->name != 'Puffin') {
  11. $this->data->browser->name = 'Puffin';
  12. $this->data->browser->version = null;
  13. $this->data->browser->stock = false;
  14. }
  15. $this->data->device->type = 'mobile';
  16. if (count($parts) > 1 && $parts[0] == 'Android') {
  17. if (!isset($this->data->os->name) || $this->data->os->name != 'Android') {
  18. $this->data->os->name = 'Android';
  19. $this->data->os->version = null;
  20. }
  21. $device = Data\DeviceModels::identify('android', $parts[1]);
  22. if ($device->identified) {
  23. $device->identified |= $this->data->device->identified;
  24. $this->data->device = $device;
  25. }
  26. }
  27. if (count($parts) > 1 && $parts[0] == 'iPhone OS') {
  28. if (!isset($this->data->os->name) || $this->data->os->name != 'iOS') {
  29. $this->data->os->name = 'iOS';
  30. $this->data->os->version = null;
  31. }
  32. $device = Data\DeviceModels::identify('ios', $parts[1]);
  33. if ($device->identified) {
  34. $device->identified |= $this->data->device->identified;
  35. $this->data->device = $device;
  36. }
  37. }
  38. }
  39. }