Browscap\Data\PropertyHolder::isOutputProperty PHP Method

isOutputProperty() public method

Determine if the specified property is an "extra" property (that should be included in the "full" versions of the files)
public isOutputProperty ( string $propertyName, Browscap\Writer\WriterInterface $writer = null ) : boolean
$propertyName string
$writer Browscap\Writer\WriterInterface
return boolean
    public function isOutputProperty($propertyName, WriterInterface $writer = null)
    {
        $outputProperties = ['Comment' => 1, 'Browser' => 1, 'Browser_Maker' => 1, 'Browser_Modus' => 1, 'Platform' => 1, 'Platform_Name' => 1, 'Platform_Description' => 1, 'Device_Name' => 1, 'Platform_Maker' => 1, 'Device_Code_Name' => 1, 'Device_Maker' => 1, 'Device_Brand_Name' => 1, 'RenderingEngine_Name' => 1, 'RenderingEngine_Description' => 1, 'RenderingEngine_Maker' => 1, 'Parent' => 1, 'Browser_Type' => 1, 'Device_Type' => 1, 'Device_Pointing_Method' => 1, 'Browser_Bits' => 1, 'Platform_Bits' => 1, 'Platform_Version' => 1, 'RenderingEngine_Version' => 1, 'Version' => 1, 'CssVersion' => 1, 'AolVersion' => 1, 'MajorVer' => 1, 'MinorVer' => 1, 'Alpha' => 1, 'Beta' => 1, 'Win16' => 1, 'Win32' => 1, 'Win64' => 1, 'Frames' => 1, 'IFrames' => 1, 'Tables' => 1, 'Cookies' => 1, 'BackgroundSounds' => 1, 'JavaScript' => 1, 'VBScript' => 1, 'JavaApplets' => 1, 'ActiveXControls' => 1, 'isMobileDevice' => 1, 'isTablet' => 1, 'isSyndicationReader' => 1, 'Crawler' => 1, 'isFake' => 1, 'isAnonymized' => 1, 'isModified' => 1];
        if (isset($outputProperties[$propertyName])) {
            return true;
        }
        if (null !== $writer && in_array($writer->getType(), ['csv', 'xml'])) {
            $additionalProperties = ['PropertyName', 'MasterParent', 'LiteMode'];
            if (in_array($propertyName, $additionalProperties)) {
                return true;
            }
        }
        return false;
    }

Usage Example

Example #1
0
 /**
  * @dataProvider userAgentDataProvider
  * @coversNothing
  *
  * @param string $userAgent
  * @param array  $expectedProperties
  * @param bool   $lite
  *
  * @group integration
  * @group useragenttest
  * @group lite
  */
 public function testUserAgentsLite($userAgent, $expectedProperties, $lite = true)
 {
     if (!is_array($expectedProperties) || !count($expectedProperties)) {
         self::markTestSkipped('Could not run test - no properties were defined to test');
     }
     if (!$lite) {
         self::markTestSkipped('Test skipped - Browser/Platform/Version not defined for Lite Mode');
     }
     self::$browscap->iniFilename = 'lite_browscap.ini';
     self::$browscap->localFile = self::$buildFolder . '/lite_php_browscap.ini';
     self::$browscap->cacheFilename = 'cache-lite.php';
     self::$browscap->doAutoUpdate = false;
     self::$browscap->silent = false;
     self::$browscap->updateMethod = Browscap::UPDATE_LOCAL;
     static $updatedLiteCache = false;
     if (!$updatedLiteCache) {
         self::$browscap->updateCache();
         $updatedLiteCache = true;
     }
     $actualProps = (array) self::$browscap->getBrowser($userAgent);
     foreach ($expectedProperties as $propName => $propValue) {
         if (!self::$propertyHolder->isOutputProperty($propName)) {
             continue;
         }
         if (!self::$propertyHolder->isLiteModeProperty($propName)) {
             continue;
         }
         self::assertArrayHasKey($propName, $actualProps, 'Actual properties did not have "' . $propName . '" property');
         self::assertSame($propValue, $actualProps[$propName], 'Expected actual "' . $propName . '" to be "' . $propValue . '" (was "' . $actualProps[$propName] . '"; used pattern: ' . $actualProps['browser_name_pattern'] . ')');
     }
 }
All Usage Examples Of Browscap\Data\PropertyHolder::isOutputProperty