toString() public méthode

Get the combined name of the manufacturer and model in a human readable format
public toString ( ) : string
Résultat string
Exemple #1
0
 /**
  * Get a human readable string of the whole browser identification
  *
  * @return string
  */
 public function toString()
 {
     $prefix = $this->camouflage ? 'an unknown browser that imitates ' : '';
     $browser = $this->browser->toString();
     $os = $this->os->toString();
     $engine = $this->engine->toString();
     $device = $this->device->toString();
     if (empty($device) && empty($os) && $this->device->type == 'television') {
         $device = 'television';
     }
     if (empty($device) && $this->device->type == 'emulator') {
         $device = 'emulator';
     }
     if (!empty($browser) && !empty($os) && !empty($device)) {
         return $prefix . $browser . ' on ' . $this->a($device) . ' running ' . $os;
     }
     if (!empty($browser) && empty($os) && !empty($device)) {
         return $prefix . $browser . ' on ' . $this->a($device);
     }
     if (!empty($browser) && !empty($os) && empty($device)) {
         return $prefix . $browser . ' on ' . $os;
     }
     if (empty($browser) && !empty($os) && !empty($device)) {
         return $prefix . $this->a($device) . ' running ' . $os;
     }
     if (!empty($browser) && empty($os) && empty($device)) {
         return $prefix . $browser;
     }
     if (empty($browser) && empty($os) && !empty($device)) {
         return $prefix . $this->a($device);
     }
     if ($this->device->type == 'desktop' && !empty($os) && !empty($engine) && empty($device)) {
         return 'an unknown browser based on ' . $engine . ' running on ' . $os;
     }
     if ($this->browser->stock && !empty($os) && empty($device)) {
         return $os;
     }
     if ($this->browser->stock && !empty($engine) && empty($device)) {
         return 'an unknown browser based on ' . $engine;
     }
     if ($this->device->type == 'bot') {
         return 'an unknown bot';
     }
     return 'an unknown browser';
 }
Exemple #2
0
 public function testToString()
 {
     $device = new Device();
     $this->assertEquals('', $device->toString());
     $device->setIdentification(['manufacturer' => 'Kobo', 'series' => 'eReader']);
     $this->assertEquals('Kobo eReader', $device->toString());
     $device->setIdentification(['manufacturer' => 'Nintendo', 'model' => 'Wii']);
     $this->assertEquals('Nintendo Wii', $device->toString());
     $device->setIdentification(['manufacturer' => 'Sony', 'model' => 'PRS-T2', 'series' => 'Reader']);
     $this->assertEquals('Sony PRS-T2 Reader', $device->toString());
     $device->setIdentification(['manufacturer' => 'Apple', 'model' => 'AppleTV']);
     $this->assertEquals('AppleTV', $device->toString());
     $device->setIdentification(['manufacturer' => 'OUYA', 'model' => 'OUYA']);
     $this->assertEquals('OUYA', $device->toString());
     $device->setIdentification(['manufacturer' => 'Apple', 'model' => 'Macintosh', 'hidden' => true]);
     $this->assertEquals('', $device->toString());
 }