toString() публичный Метод

Get a combined name and version number in a human readable format
public toString ( ) : string
Результат string
Пример #1
0
 public function testIsToString()
 {
     $browser = new Browser();
     $this->assertEquals('', $browser->toString());
     $browser->reset(['name' => 'Chrome', 'version' => new Version(['value' => '47.0.2526.73', 'details' => 1])]);
     $this->assertEquals('Chrome 47', $browser->toString());
     $browser->reset(['name' => 'Safari', 'version' => new Version(['value' => '8.0']), 'hidden' => true]);
     $this->assertEquals('', $browser->toString());
     $browser->reset(['name' => 'TestBrowser', 'using' => new Using(['name' => 'Crosswalk Webview'])]);
     $this->assertEquals('TestBrowser', $browser->toString());
     $browser->reset(['using' => new Using(['name' => 'Crosswalk Webview'])]);
     $this->assertEquals('Crosswalk Webview', $browser->toString());
 }
Пример #2
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';
 }