Browscap\Data\DataCollection::getPlatform PHP Method

getPlatform() public method

Get a single platform data array
public getPlatform ( string $platform ) : Platform
$platform string
return Platform
    public function getPlatform($platform)
    {
        if (!array_key_exists($platform, $this->platforms)) {
            throw new \OutOfBoundsException('Platform "' . $platform . '" does not exist in data');
        }
        return $this->platforms[$platform];
    }

Usage Example

 /**
  * tests getting an exiting platform
  *
  * @group data
  * @group sourcetest
  */
 public function testGetPlatform()
 {
     $this->object->addPlatformsFile($this->getPlatformsJsonFixture());
     self::assertInternalType('array', $this->object->getPlatforms());
     $platform = $this->object->getPlatform('Platform1');
     self::assertInstanceOf('\\Browscap\\Data\\Platform', $platform);
     $properties = $platform->getProperties();
     self::assertInternalType('array', $properties);
     self::assertArrayHasKey('Platform', $properties);
     self::assertSame('Platform1', $properties['Platform']);
 }