Browscap\Data\PropertyHolder::isStandardModeProperty PHP Method

isStandardModeProperty() public method

Determine if the specified property is an property that should be included in the "full" versions of the files only
public isStandardModeProperty ( string $propertyName, Browscap\Writer\WriterInterface $writer = null ) : boolean
$propertyName string
$writer Browscap\Writer\WriterInterface
return boolean
    public function isStandardModeProperty($propertyName, WriterInterface $writer = null)
    {
        $outputProperties = ['MajorVer' => 1, 'MinorVer' => 1, 'Crawler' => 1, 'Browser_Maker' => 1, 'Device_Pointing_Method' => 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
  *
  * @group integration
  * @group useragenttest
  * @group standard
  */
 public function testUserAgentsStandard($userAgent, $expectedProperties)
 {
     if (!is_array($expectedProperties) || !count($expectedProperties)) {
         self::markTestSkipped('Could not run test - no properties were defined to test');
     }
     self::$browscap->iniFilename = 'browscap.ini';
     self::$browscap->localFile = self::$buildFolder . '/php_browscap.ini';
     self::$browscap->cacheFilename = 'cache-standard.php';
     self::$browscap->doAutoUpdate = false;
     self::$browscap->silent = false;
     self::$browscap->updateMethod = Browscap::UPDATE_LOCAL;
     static $updatedStandardCache = false;
     if (!$updatedStandardCache) {
         self::$browscap->updateCache();
         $updatedStandardCache = true;
     }
     $actualProps = (array) self::$browscap->getBrowser($userAgent);
     foreach ($expectedProperties as $propName => $propValue) {
         if (!self::$propertyHolder->isOutputProperty($propName)) {
             continue;
         }
         if (!self::$propertyHolder->isStandardModeProperty($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::isStandardModeProperty