code
stringlengths 31
1.39M
| docstring
stringlengths 23
16.8k
| func_name
stringlengths 1
126
| language
stringclasses 1
value | repo
stringlengths 7
63
| path
stringlengths 7
166
| url
stringlengths 50
220
| license
stringclasses 7
values |
---|---|---|---|---|---|---|---|
public function validate(
array $divisionData,
string $filename,
array $allDivisions = [],
bool $isCore = false,
): array {
Assertion::keyExists($divisionData, 'division', 'required attibute "division" is missing in File ' . $filename);
Assertion::string($divisionData['division'], 'required attibute "division" has to be a string in File ' . $filename);
Assertion::keyExists($divisionData, 'sortIndex', 'required attibute "sortIndex" is missing in File ' . $filename);
Assertion::integer($divisionData['sortIndex'], 'required attibute "sortIndex" has to be a integer in File ' . $filename);
if (! $isCore) {
Assertion::greaterThan($divisionData['sortIndex'], 0, 'required attibute "sortIndex" has to be a positive integer in File ' . $filename);
}
Assertion::keyExists($divisionData, 'lite', 'required attibute "lite" is missing in File ' . $filename);
Assertion::boolean($divisionData['lite'], 'required attibute "lite" has to be an boolean in File ' . $filename);
Assertion::keyExists($divisionData, 'standard', 'required attibute "standard" is missing in File ' . $filename);
Assertion::boolean($divisionData['standard'], 'required attibute "standard" has to be an boolean in File ' . $filename);
Assertion::keyExists($divisionData, 'userAgents', 'required attibute "userAgents" is missing in File ' . $filename);
Assertion::isArray($divisionData['userAgents'], 'required attibute "userAgents" should be an array in File ' . $filename);
Assertion::notEmpty($divisionData['userAgents'], 'required attibute "userAgents" should be an non-empty array in File ' . $filename);
if (isset($divisionData['versions']) && is_array($divisionData['versions'])) {
$versions = $divisionData['versions'];
} else {
$versions = ['0.0'];
}
foreach ($divisionData['userAgents'] as $index => $useragentData) {
$this->validateUserAgentSection($useragentData, $versions, $allDivisions, $isCore, $filename, $index);
$allDivisions[] = $useragentData['userAgent'];
}
return $allDivisions;
} | valdates the structure of a division
@param mixed[] $divisionData Data to validate
@param string[] $allDivisions
@phpstan-param DivisionData $divisionData
@return string[]
@throws AssertionFailedException
@throws LogicException | validate | php | browscap/browscap | src/Browscap/Data/Validator/DivisionDataValidator.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Data/Validator/DivisionDataValidator.php | MIT |
private function validateUserAgentSection(
array $useragentData,
array $versions,
array $allDivisions,
bool $isCore,
string $filename,
int $index,
): void {
Assertion::keyExists($useragentData, 'userAgent', 'required attibute "userAgent" is missing in userAgents section ' . $index . ' in File ' . $filename);
Assertion::string($useragentData['userAgent'], 'required attibute "userAgent" has to be a string in userAgents section ' . $index . ' in File ' . $filename);
if (preg_match('/[\[\]]/', $useragentData['userAgent'])) {
throw new LogicException('required attibute "userAgent" includes invalid characters in userAgents section ' . $index . ' in File ' . $filename);
}
if (
mb_strpos($useragentData['userAgent'], '#') === false
&& in_array($useragentData['userAgent'], $allDivisions)
) {
throw new LogicException('Division "' . $useragentData['userAgent'] . '" is defined twice in file "' . $filename . '"');
}
if (
(mb_strpos($useragentData['userAgent'], '#MAJORVER#') !== false
|| mb_strpos($useragentData['userAgent'], '#MINORVER#') !== false)
&& $versions === ['0.0']
) {
throw new LogicException(
'Division "' . $useragentData['userAgent']
. '" is defined with version placeholders, but no versions are set in file "' . $filename . '"',
);
}
if (
mb_strpos($useragentData['userAgent'], '#MAJORVER#') === false
&& mb_strpos($useragentData['userAgent'], '#MINORVER#') === false
&& $versions !== ['0.0']
&& 1 < count($versions)
) {
throw new LogicException(
'Division "' . $useragentData['userAgent']
. '" is defined without version placeholders, but there are versions set in file "' . $filename . '"',
);
}
Assertion::keyExists($useragentData, 'properties', 'required attibute "properties" is missing in userAgents section ' . $index . ' in File ' . $filename);
Assertion::isArray($useragentData['properties'], 'required attibute "properties" should be an array in userAgents section ' . $index . ' in File ' . $filename);
Assertion::notEmpty($useragentData['properties'], 'required attibute "properties" should be an non-empty array in userAgents section ' . $index . ' in File ' . $filename);
if (! $isCore) {
Assertion::keyExists($useragentData['properties'], 'Parent', 'the "Parent" property is missing for key "' . $useragentData['userAgent'] . '" in file "' . $filename . '"');
Assertion::same($useragentData['properties']['Parent'], 'DefaultProperties', 'the "Parent" property is not linked to the "DefaultProperties" for key "' . $useragentData['userAgent'] . '" in file "' . $filename . '"');
}
Assertion::keyExists($useragentData['properties'], 'Comment', 'the "Comment" property is missing for key "' . $useragentData['userAgent'] . '" in file "' . $filename . '"');
Assertion::string($useragentData['properties']['Comment'], 'the "Comment" property has to be a string for key "' . $useragentData['userAgent'] . '" in file "' . $filename . '"');
if (! array_key_exists('Version', $useragentData['properties']) && $versions !== ['0.0']) {
throw new LogicException(
'the "Version" property is missing for key "' . $useragentData['userAgent'] . '" in file "' . $filename
. '", but there are defined versions',
);
}
if ($isCore) {
return;
}
if (array_key_exists('Version', $useragentData['properties'])) {
Assertion::string($useragentData['properties']['Version'], 'the "Version" property has to be a string for key "' . $useragentData['userAgent'] . '" in file "' . $filename . '"');
if (
(mb_strpos($useragentData['properties']['Version'], '#MAJORVER#') !== false
|| mb_strpos($useragentData['properties']['Version'], '#MINORVER#') !== false)
&& $versions === ['0.0']
) {
throw new LogicException(
'the "Version" property has version placeholders for key "' . $useragentData['userAgent'] . '" in file "' . $filename
. '", but no versions are defined',
);
}
if (
mb_strpos($useragentData['properties']['Version'], '#MAJORVER#') === false
&& mb_strpos($useragentData['properties']['Version'], '#MINORVER#') === false
&& $versions !== ['0.0']
&& 1 < count($versions)
) {
throw new LogicException(
'the "Version" property has no version placeholders for key "' . $useragentData['userAgent'] . '" in file "' . $filename
. '", but versions are defined',
);
}
}
$this->checkPlatformProperties(
$useragentData['properties'],
'the properties array contains platform data for key "' . $useragentData['userAgent']
. '", please use the "platform" keyword',
);
$this->checkEngineProperties(
$useragentData['properties'],
'the properties array contains engine data for key "' . $useragentData['userAgent']
. '", please use the "engine" keyword',
);
$this->checkDeviceProperties(
$useragentData['properties'],
'the properties array contains device data for key "' . $useragentData['userAgent']
. '", please use the "device" keyword',
);
$this->checkBrowserProperties(
$useragentData['properties'],
'the properties array contains browser data for key "' . $useragentData['userAgent']
. '", please use the "browser" keyword',
);
$this->checkDeprecatedProperties(
$useragentData['properties'],
'the properties array contains deprecated properties for key "' . $useragentData['userAgent'] . '"',
);
Assertion::keyExists($useragentData, 'children', 'required attibute "children" is missing in userAgents section ' . $index . ' in File ' . $filename);
Assertion::isArray($useragentData['children'], 'required attibute "children" should be an array in userAgents section ' . $index . ' in File ' . $filename);
Assertion::notEmpty($useragentData['children'], 'required attibute "children" should be an non-empty array in userAgents section ' . $index . ' in File ' . $filename);
Assertion::keyNotExists($useragentData['children'], 'match', 'the children property shall not have the "match" entry for key "' . $useragentData['userAgent'] . '" in file "' . $filename . '"');
foreach ($useragentData['children'] as $child) {
Assertion::isArray($child, 'each entry of the children property has to be an array for key "' . $useragentData['userAgent'] . '"');
$this->validateChildSection($child, $useragentData, $versions);
}
} | @param mixed[] $useragentData
@param array<int, int|string> $versions
@param string[] $allDivisions
@phpstan-param UserAgentData $useragentData
@throws AssertionFailedException
@throws LogicException | validateUserAgentSection | php | browscap/browscap | src/Browscap/Data/Validator/DivisionDataValidator.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Data/Validator/DivisionDataValidator.php | MIT |
private function validateChildSection(array $childData, array $useragentData, array $versions): void
{
if (array_key_exists('device', $childData) && array_key_exists('devices', $childData)) {
throw new LogicException(
'a child entry may not define both the "device" and the "devices" entries for key "'
. $useragentData['userAgent'] . '"',
);
}
if (array_key_exists('devices', $childData)) {
Assertion::isArray($childData['devices'], 'the "devices" entry for key "' . $useragentData['userAgent'] . '" has to be an array');
if (
1 < count($childData['devices'])
&& mb_strpos($childData['match'], '#DEVICE#') === false
) {
throw new LogicException(
'the "devices" entry contains multiple devices but there is no #DEVICE# token for key "'
. $useragentData['userAgent'] . '"',
);
}
}
if (array_key_exists('device', $childData)) {
Assertion::string($childData['device'], 'the "device" entry has to be a string for key "' . $useragentData['userAgent'] . '"');
}
Assertion::keyExists($childData, 'match', 'each entry of the children property requires an "match" entry for key "' . $useragentData['userAgent'] . '"');
Assertion::string($childData['match'], 'the "match" entry for key "' . $useragentData['userAgent'] . '" has to be a string');
if (preg_match('/[\[\]]/', $childData['match'])) {
throw new LogicException('key "' . $childData['match'] . '" includes invalid characters');
}
Assertion::notSame($childData['match'], $useragentData['userAgent'], 'the "match" entry is identical to its parents "userAgent" entry');
if (
mb_strpos($childData['match'], '#PLATFORM#') !== false
&& ! array_key_exists('platforms', $childData)
) {
throw new LogicException(
'the key "' . $childData['match']
. '" is defined with platform placeholder, but no platforms are assigned',
);
}
if (array_key_exists('platforms', $childData)) {
Assertion::isArray($childData['platforms'], 'the "platforms" entry for key "' . $useragentData['userAgent'] . '" has to be an array');
if (
1 < count($childData['platforms'])
&& mb_strpos($childData['match'], '#PLATFORM#') === false
) {
throw new LogicException(
'the "platforms" entry contains multiple platforms but there is no #PLATFORM# token for key "'
. $useragentData['userAgent'] . '"',
);
}
}
if (
(mb_strpos($childData['match'], '#MAJORVER#') !== false
|| mb_strpos($childData['match'], '#MINORVER#') !== false)
&& $versions === ['0.0']
) {
throw new LogicException(
'the key "' . $childData['match']
. '" is defined with version placeholders, but no versions are set',
);
}
if (
mb_strpos($childData['match'], '#MAJORVER#') === false
&& mb_strpos($childData['match'], '#MINORVER#') === false
&& $versions !== ['0.0']
&& 1 < count($versions)
) {
if (! array_key_exists('platforms', $childData)) {
throw new LogicException(
'the key "' . $childData['match']
. '" is defined without version placeholders, but there are versions set',
);
}
$dynamicPlatforms = false;
foreach ($childData['platforms'] as $platform) {
if (mb_stripos($platform, 'dynamic') !== false) {
$dynamicPlatforms = true;
break;
}
}
if (! $dynamicPlatforms) {
throw new LogicException(
'the key "' . $childData['match']
. '" is defined without version placeholders, but there are versions set',
);
}
}
if (
mb_strpos($childData['match'], '#DEVICE#') !== false
&& ! array_key_exists('devices', $childData)
) {
throw new LogicException(
'the key "' . $childData['match']
. '" is defined with device placeholder, but no devices are assigned',
);
}
if (! array_key_exists('properties', $childData)) {
return;
}
Assertion::isArray($childData['properties'], 'the "properties" entry for key "' . $childData['match'] . '" has to be an array');
Assertion::keyNotExists($childData['properties'], 'Parent', 'the Parent property must not set inside the children array for key "' . $childData['match'] . '"');
if (
array_key_exists('Version', $childData['properties'])
&& array_key_exists('properties', $useragentData)
&& array_key_exists('Version', $useragentData['properties'])
&& $useragentData['properties']['Version'] === $childData['properties']['Version']
) {
throw new LogicException(
'the "Version" property is set for key "' . $childData['match']
. '", but was already set for its parent "' . $useragentData['userAgent'] . '" with the same value',
);
}
$this->checkPlatformProperties(
$childData['properties'],
'the properties array contains platform data for key "' . $childData['match']
. '", please use the "platforms" keyword',
);
$this->checkEngineProperties(
$childData['properties'],
'the properties array contains engine data for key "' . $childData['match']
. '", please use the "engine" keyword',
);
$this->checkDeviceProperties(
$childData['properties'],
'the properties array contains device data for key "' . $childData['match']
. '", please use the "device" or the "devices" keyword',
);
$this->checkBrowserProperties(
$childData['properties'],
'the properties array contains browser data for key "' . $childData['match']
. '", please use the "browser" keyword',
);
$this->checkDeprecatedProperties(
$childData['properties'],
'the properties array contains deprecated properties for key "' . $childData['match'] . '"',
);
} | @param mixed[] $childData The children section to be validated
@param mixed[] $useragentData The complete UserAgent section which is the parent of the children section
@param array<int, int|string> $versions The versions from the division
@throws LogicException
@throws AssertionFailedException | validateChildSection | php | browscap/browscap | src/Browscap/Data/Validator/DivisionDataValidator.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Data/Validator/DivisionDataValidator.php | MIT |
private function checkPlatformProperties(array $properties, string $message): void
{
if (
array_key_exists('Platform', $properties)
|| array_key_exists('Platform_Description', $properties)
|| array_key_exists('Platform_Maker', $properties)
|| array_key_exists('Platform_Bits', $properties)
|| array_key_exists('Platform_Version', $properties)
|| array_key_exists('Win16', $properties)
|| array_key_exists('Win32', $properties)
|| array_key_exists('Win64', $properties)
|| array_key_exists('Browser_Bits', $properties)
) {
throw new LogicException($message);
}
} | checks if platform properties are set inside a properties array
@param mixed[] $properties
@throws LogicException | checkPlatformProperties | php | browscap/browscap | src/Browscap/Data/Validator/DivisionDataValidator.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Data/Validator/DivisionDataValidator.php | MIT |
public function checkEngineProperties(array $properties, string $message): void
{
if (
array_key_exists('RenderingEngine_Name', $properties)
|| array_key_exists('RenderingEngine_Version', $properties)
|| array_key_exists('RenderingEngine_Description', $properties)
|| array_key_exists('RenderingEngine_Maker', $properties)
|| array_key_exists('VBScript', $properties)
|| array_key_exists('ActiveXControls', $properties)
|| array_key_exists('BackgroundSounds', $properties)
) {
throw new LogicException($message);
}
} | checks if platform properties are set inside a properties array
@param mixed[] $properties
@throws LogicException | checkEngineProperties | php | browscap/browscap | src/Browscap/Data/Validator/DivisionDataValidator.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Data/Validator/DivisionDataValidator.php | MIT |
public function checkDeviceProperties(array $properties, string $message): void
{
if (
array_key_exists('Device_Name', $properties)
|| array_key_exists('Device_Maker', $properties)
|| array_key_exists('Device_Type', $properties)
|| array_key_exists('Device_Pointing_Method', $properties)
|| array_key_exists('Device_Code_Name', $properties)
|| array_key_exists('Device_Brand_Name', $properties)
|| array_key_exists('isMobileDevice', $properties)
|| array_key_exists('isTablet', $properties)
) {
throw new LogicException($message);
}
} | checks if device properties are set inside a properties array
@param mixed[] $properties
@throws LogicException | checkDeviceProperties | php | browscap/browscap | src/Browscap/Data/Validator/DivisionDataValidator.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Data/Validator/DivisionDataValidator.php | MIT |
public function checkBrowserProperties(array $properties, string $message): void
{
if (
array_key_exists('Browser', $properties)
|| array_key_exists('Browser_Type', $properties)
|| array_key_exists('Browser_Maker', $properties)
|| array_key_exists('isSyndicationReader', $properties)
|| array_key_exists('Crawler', $properties)
) {
throw new LogicException($message);
}
} | checks if browser properties are set inside a properties array
@param mixed[] $properties
@throws LogicException | checkBrowserProperties | php | browscap/browscap | src/Browscap/Data/Validator/DivisionDataValidator.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Data/Validator/DivisionDataValidator.php | MIT |
public function checkDeprecatedProperties(array $properties, string $message): void
{
if (
array_key_exists('AolVersion', $properties)
|| array_key_exists('MinorVer', $properties)
|| array_key_exists('MajorVer', $properties)
) {
throw new LogicException($message);
}
} | checks if deprecated properties are set inside a properties array
@param mixed[] $properties
@throws LogicException | checkDeprecatedProperties | php | browscap/browscap | src/Browscap/Data/Validator/DivisionDataValidator.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Data/Validator/DivisionDataValidator.php | MIT |
public function validate(array $properties, string $key): void
{
if (! in_array($key, ['DefaultProperties', '*'])) {
Assertion::keyExists($properties, 'Parent', 'property "Parent" is missing for key "' . $key . '"');
Assertion::string($properties['Parent'], 'property "Parent" must be a String for key "' . $key . '", got "%s"');
}
Assertion::keyExists($properties, 'Comment', 'property "Comment" not found for key "' . $key . '"');
Assertion::string($properties['Comment'], 'property "Comment" must be a String for key "' . $key . '", got "%s"');
Assertion::keyExists($properties, 'Browser', 'property "Browser" not found for key "' . $key . '"');
Assertion::string($properties['Browser'], 'property "Browser" must be a String for key "' . $key . '", got "%s"');
Assertion::keyExists($properties, 'Browser_Type', 'property "Browser_Type" not found for key "' . $key . '"');
Assertion::string($properties['Browser_Type'], 'property "Browser_Type" must be a String for key "' . $key . '", got "%s"');
Assertion::keyExists($properties, 'Browser_Bits', 'property "Browser_Bits" not found for key "' . $key . '"');
Assertion::integer($properties['Browser_Bits'], 'property "Browser_Bits" must be a Integer for key "' . $key . '", got "%s"');
Assertion::keyExists($properties, 'Browser_Maker', 'property "Browser_Maker" not found for key "' . $key . '"');
Assertion::string($properties['Browser_Maker'], 'property "Browser_Maker" must be a String for key "' . $key . '", got "%s"');
Assertion::keyExists($properties, 'Browser_Modus', 'property "Browser_Modus" not found for key "' . $key . '"');
Assertion::string($properties['Browser_Modus'], 'property "Browser_Modus" must be a String for key "' . $key . '", got "%s"');
Assertion::keyExists($properties, 'Version', 'property "Version" not found for key "' . $key . '"');
Assertion::string($properties['Version'], 'property "Version" must be a String for key "' . $key . '", got "%s"');
Assertion::keyExists($properties, 'MajorVer', 'property "MajorVer" not found for key "' . $key . '"');
Assertion::string($properties['MajorVer'], 'property "MajorVer" must be a String for key "' . $key . '", got "%s"');
Assertion::keyExists($properties, 'MinorVer', 'property "MinorVer" not found for key "' . $key . '"');
Assertion::string($properties['MinorVer'], 'property "MinorVer" must be a String for key "' . $key . '", got "%s"');
Assertion::keyExists($properties, 'Platform', 'property "Platform" not found for key "' . $key . '"');
Assertion::string($properties['Platform'], 'property "Platform" must be a String for key "' . $key . '", got "%s"');
Assertion::keyExists($properties, 'Platform_Version', 'property "Platform_Version" not found for key "' . $key . '"');
Assertion::string($properties['Platform_Version'], 'property "Platform_Version" must be a String for key "' . $key . '", got "%s"');
Assertion::keyExists($properties, 'Platform_Description', 'property "Platform_Description" not found for key "' . $key . '"');
Assertion::string($properties['Platform_Description'], 'property "Platform_Description" must be a String for key "' . $key . '", got "%s"');
Assertion::keyExists($properties, 'Platform_Bits', 'property "Platform_Bits" not found for key "' . $key . '"');
Assertion::integer($properties['Platform_Bits'], 'property "Platform_Bits" must be a Integer for key "' . $key . '", got "%s"');
Assertion::keyExists($properties, 'Platform_Maker', 'property "Platform_Maker" not found for key "' . $key . '"');
Assertion::string($properties['Platform_Maker'], 'property "Platform_Maker" must be a String for key "' . $key . '", got "%s"');
Assertion::keyExists($properties, 'Alpha', 'property "Alpha" not found for key "' . $key . '"');
Assertion::boolean($properties['Alpha'], 'property "Alpha" must be a Boolean for key "' . $key . '", got "%s"');
Assertion::keyExists($properties, 'Beta', 'property "Beta" not found for key "' . $key . '"');
Assertion::boolean($properties['Beta'], 'property "Beta" must be a Boolean for key "' . $key . '", got "%s"');
Assertion::keyExists($properties, 'Win16', 'property "Win16" not found for key "' . $key . '"');
Assertion::boolean($properties['Win16'], 'property "Win16" must be a Boolean for key "' . $key . '", got "%s"');
Assertion::keyExists($properties, 'Win32', 'property "Win32" not found for key "' . $key . '"');
Assertion::boolean($properties['Win32'], 'property "Win32" must be a Boolean for key "' . $key . '", got "%s"');
Assertion::keyExists($properties, 'Win64', 'property "Win64" not found for key "' . $key . '"');
Assertion::boolean($properties['Win64'], 'property "Win64" must be a Boolean for key "' . $key . '", got "%s"');
Assertion::keyExists($properties, 'Frames', 'property "Frames" not found for key "' . $key . '"');
Assertion::boolean($properties['Frames'], 'property "Frames" must be a Boolean for key "' . $key . '", got "%s"');
Assertion::keyExists($properties, 'IFrames', 'property "IFrames" not found for key "' . $key . '"');
Assertion::boolean($properties['IFrames'], 'property "IFrames" must be a Boolean for key "' . $key . '", got "%s"');
Assertion::keyExists($properties, 'Tables', 'property "Tables" not found for key "' . $key . '"');
Assertion::boolean($properties['Tables'], 'property "Tables" must be a Boolean for key "' . $key . '", got "%s"');
Assertion::keyExists($properties, 'Cookies', 'property "Cookies" not found for key "' . $key . '"');
Assertion::boolean($properties['Cookies'], 'property "Cookies" must be a Boolean for key "' . $key . '", got "%s"');
Assertion::keyExists($properties, 'BackgroundSounds', 'property "BackgroundSounds" not found for key "' . $key . '"');
Assertion::boolean($properties['BackgroundSounds'], 'property "BackgroundSounds" must be a Boolean for key "' . $key . '", got "%s"');
Assertion::keyExists($properties, 'JavaScript', 'property "JavaScript" not found for key "' . $key . '"');
Assertion::boolean($properties['JavaScript'], 'property "JavaScript" must be a Boolean for key "' . $key . '", got "%s"');
Assertion::keyExists($properties, 'VBScript', 'property "VBScript" not found for key "' . $key . '"');
Assertion::boolean($properties['VBScript'], 'property "VBScript" must be a Boolean for key "' . $key . '", got "%s"');
Assertion::keyExists($properties, 'JavaApplets', 'property "JavaApplets" not found for key "' . $key . '"');
Assertion::boolean($properties['JavaApplets'], 'property "JavaApplets" must be a Boolean for key "' . $key . '", got "%s"');
Assertion::keyExists($properties, 'ActiveXControls', 'property "ActiveXControls" not found for key "' . $key . '"');
Assertion::boolean($properties['ActiveXControls'], 'property "ActiveXControls" must be a Boolean for key "' . $key . '", got "%s"');
Assertion::keyExists($properties, 'isMobileDevice', 'property "isMobileDevice" is missing for key "' . $key . '"');
Assertion::boolean($properties['isMobileDevice'], 'property "isMobileDevice" must be a Boolean for key "' . $key . '", got "%s"');
Assertion::keyExists($properties, 'isTablet', 'property "isTablet" is missing for key "' . $key . '"');
Assertion::boolean($properties['isTablet'], 'property "isTablet" must be a Boolean for key "' . $key . '", got "%s"');
Assertion::keyExists($properties, 'isSyndicationReader', 'property "isSyndicationReader" not found for key "' . $key . '"');
Assertion::boolean($properties['isSyndicationReader'], 'property "isSyndicationReader" must be a Boolean for key "' . $key . '", got "%s"');
Assertion::keyExists($properties, 'Crawler', 'property "Crawler" not found for key "' . $key . '"');
Assertion::boolean($properties['Crawler'], 'property "Crawler" must be a Boolean for key "' . $key . '", got "%s"');
Assertion::keyExists($properties, 'isFake', 'property "isFake" not found for key "' . $key . '"');
Assertion::boolean($properties['isFake'], 'property "isFake" must be a Boolean for key "' . $key . '", got "%s"');
Assertion::keyExists($properties, 'isAnonymized', 'property "isAnonymized" not found for key "' . $key . '"');
Assertion::boolean($properties['isAnonymized'], 'property "isAnonymized" must be a Boolean for key "' . $key . '", got "%s"');
Assertion::keyExists($properties, 'isModified', 'property "isModified" not found for key "' . $key . '"');
Assertion::boolean($properties['isModified'], 'property "isModified" must be a Boolean for key "' . $key . '", got "%s"');
Assertion::keyExists($properties, 'CssVersion', 'property "CssVersion" not found for key "' . $key . '"');
Assertion::integer($properties['CssVersion'], 'property "CssVersion" must be a Integer for key "' . $key . '", got "%s"');
Assertion::keyExists($properties, 'AolVersion', 'property "AolVersion" not found for key "' . $key . '"');
Assertion::integer($properties['AolVersion'], 'property "AolVersion" must be a Integer for key "' . $key . '", got "%s"');
Assertion::keyExists($properties, 'Device_Name', 'property "Device_Name" not found for key "' . $key . '"');
Assertion::string($properties['Device_Name'], 'property "Device_Name" must be a String for key "' . $key . '", got "%s"');
Assertion::keyExists($properties, 'Device_Maker', 'property "Device_Maker" not found for key "' . $key . '"');
Assertion::string($properties['Device_Maker'], 'property "Device_Maker" must be a String for key "' . $key . '", got "%s"');
Assertion::keyExists($properties, 'Device_Type', 'property "Device_Type" is missing for key "' . $key . '"');
Assertion::string($properties['Device_Type'], 'property "Device_Type" must be a String for key "' . $key . '", got "%s"');
Assertion::keyExists($properties, 'Device_Pointing_Method', 'property "Device_Pointing_Method" not found for key "' . $key . '"');
Assertion::string($properties['Device_Pointing_Method'], 'property "Device_Pointing_Method" must be a String for key "' . $key . '", got "%s"');
Assertion::keyExists($properties, 'Device_Code_Name', 'property "Device_Code_Name" not found for key "' . $key . '"');
Assertion::string($properties['Device_Code_Name'], 'property "Device_Code_Name" must be a String for key "' . $key . '", got "%s"');
Assertion::keyExists($properties, 'Device_Brand_Name', 'property "Device_Brand_Name" not found for key "' . $key . '"');
Assertion::string($properties['Device_Brand_Name'], 'property "Device_Brand_Name" must be a String for key "' . $key . '", got "%s"');
Assertion::keyExists($properties, 'RenderingEngine_Name', 'property "RenderingEngine_Name" not found for key "' . $key . '"');
Assertion::string($properties['RenderingEngine_Name'], 'property "RenderingEngine_Name" must be a String for key "' . $key . '", got "%s"');
Assertion::keyExists($properties, 'RenderingEngine_Version', 'property "RenderingEngine_Version" not found for key "' . $key . '"');
Assertion::string($properties['RenderingEngine_Version'], 'property "RenderingEngine_Version" must be a String for key "' . $key . '", got "%s"');
Assertion::keyExists($properties, 'RenderingEngine_Description', 'property "RenderingEngine_Description" not found for key "' . $key . '"');
Assertion::string($properties['RenderingEngine_Description'], 'property "RenderingEngine_Description" must be a String for key "' . $key . '", got "%s"');
Assertion::keyExists($properties, 'RenderingEngine_Maker', 'property "RenderingEngine_Maker" not found for key "' . $key . '"');
Assertion::string($properties['RenderingEngine_Maker'], 'property "RenderingEngine_Maker" must be a String for key "' . $key . '", got "%s"');
} | validates the fully expanded properties
@param mixed[] $properties Data to validate
@throws LogicException
@throws AssertionFailedException | validate | php | browscap/browscap | src/Browscap/Data/Validator/PropertiesValidator.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Data/Validator/PropertiesValidator.php | MIT |
public function getType(): string
{
return FilterInterface::TYPE_CUSTOM;
} | returns the Type of the filter
@throws void | getType | php | browscap/browscap | src/Browscap/Filter/CustomFilter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Filter/CustomFilter.php | MIT |
public function isOutput(Division $division): bool
{
return true;
} | checks if a division should be in the output
@throws void | isOutput | php | browscap/browscap | src/Browscap/Filter/CustomFilter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Filter/CustomFilter.php | MIT |
public function isOutputSection(array $section): bool
{
return true;
} | checks if a section should be in the output
@param bool[] $section
@throws void | isOutputSection | php | browscap/browscap | src/Browscap/Filter/CustomFilter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Filter/CustomFilter.php | MIT |
public function isOutputProperty(string $property, WriterInterface $writer): bool
{
if (! $this->propertyHolder->isOutputProperty($property, $writer)) {
return false;
}
return in_array($property, $this->fields);
} | checks if a property should be in the output
@throws void | isOutputProperty | php | browscap/browscap | src/Browscap/Filter/CustomFilter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Filter/CustomFilter.php | MIT |
public function getType(): string
{
return FilterInterface::TYPE_COLLECTION;
} | returns the Type of the filter
@throws void | getType | php | browscap/browscap | src/Browscap/Filter/FilterCollection.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Filter/FilterCollection.php | MIT |
public function addFilter(FilterInterface $writer): void
{
$this->filters[] = $writer;
} | add a new filter to the collection
@throws void | addFilter | php | browscap/browscap | src/Browscap/Filter/FilterCollection.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Filter/FilterCollection.php | MIT |
public function isOutput(Division $division): bool
{
foreach ($this->filters as $filter) {
if (! $filter->isOutput($division)) {
return false;
}
}
return true;
} | checks if a division should be in the output | isOutput | php | browscap/browscap | src/Browscap/Filter/FilterCollection.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Filter/FilterCollection.php | MIT |
public function isOutputSection(array $section): bool
{
foreach ($this->filters as $filter) {
if (! $filter->isOutputSection($section)) {
return false;
}
}
return true;
} | checks if a section should be in the output
@param bool[] $section | isOutputSection | php | browscap/browscap | src/Browscap/Filter/FilterCollection.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Filter/FilterCollection.php | MIT |
public function isOutputProperty(string $property, WriterInterface $writer): bool
{
foreach ($this->filters as $filter) {
if (! $filter->isOutputProperty($property, $writer)) {
return false;
}
}
return true;
} | checks if a property should be in the output | isOutputProperty | php | browscap/browscap | src/Browscap/Filter/FilterCollection.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Filter/FilterCollection.php | MIT |
public function getType(): string
{
return FilterInterface::TYPE_FULL;
} | returns the Type of the filter
@throws void | getType | php | browscap/browscap | src/Browscap/Filter/FullFilter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Filter/FullFilter.php | MIT |
public function isOutput(Division $division): bool
{
return true;
} | checks if a division should be in the output
@throws void | isOutput | php | browscap/browscap | src/Browscap/Filter/FullFilter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Filter/FullFilter.php | MIT |
public function isOutputSection(array $section): bool
{
return true;
} | checks if a section should be in the output
@param bool[] $section
@throws void | isOutputSection | php | browscap/browscap | src/Browscap/Filter/FullFilter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Filter/FullFilter.php | MIT |
public function isOutputProperty(string $property, WriterInterface $writer): bool
{
return $this->propertyHolder->isOutputProperty($property, $writer);
} | checks if a property should be in the output
@throws void | isOutputProperty | php | browscap/browscap | src/Browscap/Filter/FullFilter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Filter/FullFilter.php | MIT |
public function getType(): string
{
return FilterInterface::TYPE_LITE;
} | returns the Type of the filter
@throws void | getType | php | browscap/browscap | src/Browscap/Filter/LiteFilter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Filter/LiteFilter.php | MIT |
public function isOutput(Division $division): bool
{
return $division->isLite();
} | checks if a division should be in the output
@throws void | isOutput | php | browscap/browscap | src/Browscap/Filter/LiteFilter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Filter/LiteFilter.php | MIT |
public function isOutputSection(array $section): bool
{
return isset($section['lite']) && $section['lite'];
} | checks if a section should be in the output
@param bool[] $section
@throws void | isOutputSection | php | browscap/browscap | src/Browscap/Filter/LiteFilter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Filter/LiteFilter.php | MIT |
public function isOutputProperty(string $property, WriterInterface $writer): bool
{
if (! $this->propertyHolder->isOutputProperty($property, $writer)) {
return false;
}
return $this->propertyHolder->isLiteModeProperty($property, $writer);
} | checks if a property should be in the output
@throws void | isOutputProperty | php | browscap/browscap | src/Browscap/Filter/LiteFilter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Filter/LiteFilter.php | MIT |
public function getType(): string
{
return FilterInterface::TYPE_STANDARD;
} | returns the Type of the filter
@throws void | getType | php | browscap/browscap | src/Browscap/Filter/StandardFilter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Filter/StandardFilter.php | MIT |
public function isOutput(Division $division): bool
{
return $division->isStandard();
} | checks if a division should be in the output
@throws void | isOutput | php | browscap/browscap | src/Browscap/Filter/StandardFilter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Filter/StandardFilter.php | MIT |
public function isOutputSection(array $section): bool
{
return ! isset($section['standard']) || $section['standard'];
} | checks if a section should be in the output
@param bool[] $section
@throws void | isOutputSection | php | browscap/browscap | src/Browscap/Filter/StandardFilter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Filter/StandardFilter.php | MIT |
public function isOutputProperty(string $property, WriterInterface $writer): bool
{
if (! $this->propertyHolder->isOutputProperty($property, $writer)) {
return false;
}
if ($this->propertyHolder->isLiteModeProperty($property, $writer)) {
return true;
}
return $this->propertyHolder->isStandardModeProperty($property, $writer);
} | checks if a property should be in the output
@throws void | isOutputProperty | php | browscap/browscap | src/Browscap/Filter/StandardFilter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Filter/StandardFilter.php | MIT |
public function getType(): string
{
return FormatterInterface::TYPE_ASP;
} | returns the Type of the formatter
@throws void | getType | php | browscap/browscap | src/Browscap/Formatter/AspFormatter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Formatter/AspFormatter.php | MIT |
public function formatPropertyName(string $name): string
{
return $name;
} | formats the name of a property
@throws void | formatPropertyName | php | browscap/browscap | src/Browscap/Formatter/AspFormatter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Formatter/AspFormatter.php | MIT |
public function formatPropertyValue(bool|int|string $value, string $property): string
{
switch ($this->propertyHolder->getPropertyType($property)) {
case PropertyHolder::TYPE_STRING:
$valueOutput = trim((string) $value);
break;
case PropertyHolder::TYPE_BOOLEAN:
if ($value === true || $value === 'true') {
$valueOutput = 'true';
} elseif ($value === false || $value === 'false') {
$valueOutput = 'false';
} else {
$valueOutput = '';
}
break;
case PropertyHolder::TYPE_IN_ARRAY:
try {
$valueOutput = (string) $this->propertyHolder->checkValueInArray($property, (string) $value);
} catch (InvalidArgumentException) {
$valueOutput = '';
}
break;
default:
$valueOutput = (string) $value;
break;
}
return $valueOutput;
} | formats the name of a property
@throws Exception | formatPropertyValue | php | browscap/browscap | src/Browscap/Formatter/AspFormatter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Formatter/AspFormatter.php | MIT |
public function getType(): string
{
return FormatterInterface::TYPE_CSV;
} | returns the Type of the formatter
@throws void | getType | php | browscap/browscap | src/Browscap/Formatter/CsvFormatter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Formatter/CsvFormatter.php | MIT |
public function formatPropertyName(string $name): string
{
return '"' . str_replace('"', '""', $name) . '"';
} | formats the name of a property
@throws void | formatPropertyName | php | browscap/browscap | src/Browscap/Formatter/CsvFormatter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Formatter/CsvFormatter.php | MIT |
public function formatPropertyValue(bool|int|string $value, string $property): string
{
$valueOutput = (string) $value;
switch ($this->propertyHolder->getPropertyType($property)) {
case PropertyHolder::TYPE_STRING:
$valueOutput = trim((string) $value);
break;
case PropertyHolder::TYPE_BOOLEAN:
if ($value === true || $value === 'true') {
$valueOutput = 'true';
} elseif ($value === false || $value === 'false') {
$valueOutput = 'false';
} else {
$valueOutput = '';
}
break;
case PropertyHolder::TYPE_IN_ARRAY:
try {
$valueOutput = (string) $this->propertyHolder->checkValueInArray($property, (string) $value);
} catch (InvalidArgumentException) {
$valueOutput = '';
}
break;
default:
// nothing t do here
break;
}
if ($valueOutput === 'unknown') {
$valueOutput = '';
}
return '"' . str_replace('"', '""', $valueOutput) . '"';
} | formats the name of a property
@throws Exception | formatPropertyValue | php | browscap/browscap | src/Browscap/Formatter/CsvFormatter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Formatter/CsvFormatter.php | MIT |
public function getType(): string
{
return FormatterInterface::TYPE_JSON;
} | returns the Type of the formatter
@throws void | getType | php | browscap/browscap | src/Browscap/Formatter/JsonFormatter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Formatter/JsonFormatter.php | MIT |
public function formatPropertyName(string $name): string
{
return json_encode($name, JSON_THROW_ON_ERROR);
} | formats the name of a property
@throws JsonException | formatPropertyName | php | browscap/browscap | src/Browscap/Formatter/JsonFormatter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Formatter/JsonFormatter.php | MIT |
public function formatPropertyValue(bool|int|string $value, string $property): string
{
switch ($this->propertyHolder->getPropertyType($property)) {
case PropertyHolder::TYPE_STRING:
$valueOutput = json_encode(trim((string) $value), JSON_THROW_ON_ERROR);
break;
case PropertyHolder::TYPE_BOOLEAN:
if ($value === true || $value === 'true') {
$valueOutput = 'true';
} elseif ($value === false || $value === 'false') {
$valueOutput = 'false';
} else {
$valueOutput = '""';
}
break;
case PropertyHolder::TYPE_IN_ARRAY:
try {
$valueOutput = json_encode($this->propertyHolder->checkValueInArray($property, (string) $value), JSON_THROW_ON_ERROR);
} catch (InvalidArgumentException) {
$valueOutput = '""';
}
break;
default:
$valueOutput = json_encode($value, JSON_THROW_ON_ERROR);
break;
}
if ($valueOutput === 'unknown' || $valueOutput === '"unknown"') {
$valueOutput = '""';
}
return $valueOutput;
} | formats the name of a property
@throws Exception
@throws JsonException | formatPropertyValue | php | browscap/browscap | src/Browscap/Formatter/JsonFormatter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Formatter/JsonFormatter.php | MIT |
public function getType(): string
{
return FormatterInterface::TYPE_PHP;
} | returns the Type of the formatter
@throws void | getType | php | browscap/browscap | src/Browscap/Formatter/PhpFormatter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Formatter/PhpFormatter.php | MIT |
public function formatPropertyName(string $name): string
{
return $name;
} | formats the name of a property
@throws void | formatPropertyName | php | browscap/browscap | src/Browscap/Formatter/PhpFormatter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Formatter/PhpFormatter.php | MIT |
public function formatPropertyValue(bool|int|string $value, string $property): string
{
$valueOutput = (string) $value;
switch ($this->propertyHolder->getPropertyType($property)) {
case PropertyHolder::TYPE_STRING:
$valueOutput = '"' . trim((string) $value) . '"';
break;
case PropertyHolder::TYPE_BOOLEAN:
if ($value === true || $value === 'true') {
$valueOutput = '"true"';
} elseif ($value === false || $value === 'false') {
$valueOutput = '"false"';
} else {
$valueOutput = '';
}
break;
case PropertyHolder::TYPE_IN_ARRAY:
try {
$valueOutput = '"' . $this->propertyHolder->checkValueInArray($property, (string) $value) . '"';
} catch (InvalidArgumentException) {
$valueOutput = '';
}
break;
default:
if (preg_match('/[^a-zA-Z0-9]/', $valueOutput)) {
$valueOutput = '"' . $valueOutput . '"';
}
// nothing t do here
break;
}
return $valueOutput;
} | formats the name of a property
@throws Exception | formatPropertyValue | php | browscap/browscap | src/Browscap/Formatter/PhpFormatter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Formatter/PhpFormatter.php | MIT |
public function getType(): string
{
return FormatterInterface::TYPE_XML;
} | returns the Type of the formatter
@throws void | getType | php | browscap/browscap | src/Browscap/Formatter/XmlFormatter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Formatter/XmlFormatter.php | MIT |
public function formatPropertyName(string $name): string
{
return htmlentities($name);
} | formats the name of a property
@throws void | formatPropertyName | php | browscap/browscap | src/Browscap/Formatter/XmlFormatter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Formatter/XmlFormatter.php | MIT |
public function formatPropertyValue(bool|int|string $value, string $property): string
{
switch ($this->propertyHolder->getPropertyType($property)) {
case PropertyHolder::TYPE_STRING:
$valueOutput = htmlentities(trim((string) $value));
break;
case PropertyHolder::TYPE_BOOLEAN:
if ($value === true || $value === 'true') {
$valueOutput = 'true';
} elseif ($value === false || $value === 'false') {
$valueOutput = 'false';
} else {
$valueOutput = '';
}
break;
case PropertyHolder::TYPE_IN_ARRAY:
try {
$valueOutput = htmlentities((string) $this->propertyHolder->checkValueInArray($property, (string) $value));
} catch (InvalidArgumentException) {
$valueOutput = '';
}
break;
default:
$valueOutput = htmlentities((string) $value);
break;
}
if ($valueOutput === 'unknown') {
$valueOutput = '';
}
return $valueOutput;
} | formats the name of a property
@throws Exception | formatPropertyValue | php | browscap/browscap | src/Browscap/Formatter/XmlFormatter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Formatter/XmlFormatter.php | MIT |
public function run(string $buildVersion, DateTimeImmutable $generationDate, bool $createZipFile = true): void
{
$this->logger->info('Resource folder: ' . $this->resourceFolder . '');
$this->logger->info('Build folder: ' . $this->buildFolder . '');
Helper\BuildHelper::run(
$buildVersion,
$generationDate,
$this->resourceFolder,
$this->logger,
$this->writerCollection,
$this->dataCollectionFactory,
$this->collectPatternIds,
);
if (! $createZipFile) {
return;
}
$this->logger->info('started creating the zip archive');
$zip = new ZipArchive();
$zip->open($this->buildFolder . '/browscap.zip', ZipArchive::CREATE | ZipArchive::OVERWRITE);
$files = [
'full_asp_browscap.ini',
'full_php_browscap.ini',
'browscap.ini',
'php_browscap.ini',
'lite_asp_browscap.ini',
'lite_php_browscap.ini',
'browscap.xml',
'browscap.csv',
'browscap.json',
];
foreach ($files as $file) {
$filePath = $this->buildFolder . '/' . $file;
if (! file_exists($filePath) || ! is_readable($filePath)) {
continue;
}
$zip->addFile($filePath, $file);
}
$zip->close();
$this->logger->info('finished creating the zip archive');
} | Entry point for generating builds for a specified version
@throws Exception
@throws AssertionFailedException | run | php | browscap/browscap | src/Browscap/Generator/BuildGenerator.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Generator/BuildGenerator.php | MIT |
public function setCollectPatternIds(bool $value): void
{
$this->collectPatternIds = $value;
} | Sets the flag to collect pattern ids during this build
@throws void | setCollectPatternIds | php | browscap/browscap | src/Browscap/Generator/BuildGenerator.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Generator/BuildGenerator.php | MIT |
public function getTestFiles(LoggerInterface $logger, string $testKey = 'full'): array
{
$data = [];
$checks = [];
$errors = [];
$sourceDirectory = __DIR__ . '/../../../tests/issues/';
$iterator = new RecursiveDirectoryIterator($sourceDirectory);
foreach (new RecursiveIteratorIterator($iterator) as $file) {
assert($file instanceof SplFileInfo);
if (! $file->isFile() || $file->getExtension() !== 'php') {
continue;
}
$tests = require $file->getPathname();
foreach ($tests as $key => $test) {
assert(is_string($key));
if (array_key_exists($key, $data)) {
$error = sprintf('Test data is duplicated for key "%s"', $key);
$logger->error($error);
$errors[] = $error;
continue;
}
if (! array_key_exists($testKey, $test)) {
$error = sprintf('"%s" keyword is missing for key "%s"', $testKey, $key);
$logger->error($error);
$errors[] = $error;
continue;
}
if (! $test[$testKey]) {
continue;
}
if (isset($checks[$test['ua']])) {
$error = sprintf(
'UA "%s" added more than once, now for key "%s", before for key "%s"',
$test['ua'],
$key,
$checks[$test['ua']],
);
$logger->error($error);
$errors[] = $error;
continue;
}
$data[$key] = $test;
$checks[$test['ua']] = $key;
}
}
return [$data, $errors];
} | @phpstan-param 'full'|'standard'|'lite' $testKey
@return array<array<string>>
@phpstan-return array{0: array<string, array{ua: string, properties: array<string, string|int|bool>, lite: bool, standard: bool, full: bool}>, 1: array<string, string>}
@throws UnexpectedValueException | getTestFiles | php | browscap/browscap | src/Browscap/Helper/IteratorHelper.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Helper/IteratorHelper.php | MIT |
public function getParsed(): array
{
return $this->data;
} | @return array<array<array<string>|string>>
@throws void | getParsed | php | browscap/browscap | src/Browscap/Parser/IniParser.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Parser/IniParser.php | MIT |
public function setFileLines(array $fileLines): void
{
$this->fileLines = $fileLines;
} | @param array<string> $fileLines
@throws void | setFileLines | php | browscap/browscap | src/Browscap/Parser/IniParser.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Parser/IniParser.php | MIT |
public function parse(): array
{
$fileLines = $this->getFileLines();
$data = [];
$currentSection = '';
$currentDivision = '';
for ($line = 0, $count = count($fileLines); $line < $count; ++$line) {
$currentLine = $fileLines[$line];
$currentLineLength = mb_strlen($currentLine);
if ($currentLineLength === 0) {
continue;
}
if (mb_substr($currentLine, 0, 40) === ';;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;') {
$currentDivision = trim(mb_substr($currentLine, 41));
continue;
}
// We only skip comments that *start* with semicolon
if ($currentLine[0] === ';') {
continue;
}
if ($currentLine[0] === '[') {
$currentSection = mb_substr($currentLine, 1, $currentLineLength - 2);
continue;
}
$bits = explode('=', $currentLine);
if (2 < count($bits)) {
throw new RuntimeException(sprintf('Too many equals in line: %s, in Division: %s', $currentLine, $currentDivision));
}
if (2 > count($bits)) {
$bits[1] = '';
}
$data[$currentSection][$bits[0]] = $bits[1];
$data[$currentSection]['Division'] = $currentDivision;
}
if ($this->shouldSort()) {
$data = $this->sortArrayAndChildArrays($data);
}
$this->data = $data;
return $data;
} | @return array<array<array<string>|string>>
@throws RuntimeException
@throws InvalidArgumentException | parse | php | browscap/browscap | src/Browscap/Parser/IniParser.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Parser/IniParser.php | MIT |
private function sortArrayAndChildArrays(array $array): array
{
ksort($array);
foreach (array_keys($array) as $key) {
if (! is_array($array[$key]) || empty($array[$key])) {
continue;
}
$array[$key] = $this->sortArrayAndChildArrays($array[$key]);
}
return $array;
} | @param array<array<string>|string> $array
@return array<array<array<string>|string>>
@throws void | sortArrayAndChildArrays | php | browscap/browscap | src/Browscap/Parser/IniParser.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Parser/IniParser.php | MIT |
public function getType(): string
{
return WriterInterface::TYPE_CSV;
} | returns the Type of the writer
@throws void | getType | php | browscap/browscap | src/Browscap/Writer/CsvWriter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Writer/CsvWriter.php | MIT |
public function close(): void
{
fclose($this->file);
} | closes the Writer and the written File
@throws void | close | php | browscap/browscap | src/Browscap/Writer/CsvWriter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Writer/CsvWriter.php | MIT |
public function fileStart(): void
{
// nothing to do here
} | Generates a start sequence for the output file
@throws void | fileStart | php | browscap/browscap | src/Browscap/Writer/CsvWriter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Writer/CsvWriter.php | MIT |
public function fileEnd(): void
{
// nothing to do here
} | Generates a end sequence for the output file
@throws void | fileEnd | php | browscap/browscap | src/Browscap/Writer/CsvWriter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Writer/CsvWriter.php | MIT |
public function renderHeader(array $comments = []): void
{
// nothing to do here
} | Generate the header
@param array<string> $comments
@throws void | renderHeader | php | browscap/browscap | src/Browscap/Writer/CsvWriter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Writer/CsvWriter.php | MIT |
public function renderVersion(array $versionData = []): void
{
if ($this->isSilent()) {
return;
}
$this->logger->debug('rendering version information');
fwrite($this->file, '"GJK_Browscap_Version","GJK_Browscap_Version"' . PHP_EOL);
if (! isset($versionData['version'])) {
$versionData['version'] = '0';
}
if (! isset($versionData['released'])) {
$versionData['released'] = '';
}
fwrite($this->file, '"' . $versionData['version'] . '","' . $versionData['released'] . '"' . PHP_EOL);
} | renders the version information
@param array<string> $versionData
@throws void | renderVersion | php | browscap/browscap | src/Browscap/Writer/CsvWriter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Writer/CsvWriter.php | MIT |
public function renderAllDivisionsHeader(DataCollection $collection): void
{
$division = $collection->getDefaultProperties();
$ua = $division->getUserAgents()[0];
assert($ua instanceof UserAgent);
if (empty($ua->getProperties())) {
return;
}
$defaultproperties = $ua->getProperties();
$properties = array_merge(
['PropertyName', 'MasterParent', 'LiteMode', 'Parent'],
array_keys($defaultproperties),
);
$values = [];
foreach ($properties as $property) {
if (! isset($this->outputProperties[$property])) {
$this->outputProperties[$property] = $this->filter->isOutputProperty((string) $property, $this);
}
if (! $this->outputProperties[$property]) {
continue;
}
$values[] = $this->formatter->formatPropertyName((string) $property);
}
fwrite($this->file, implode(',', $values) . PHP_EOL);
} | renders the header for all divisions
@throws JsonException | renderAllDivisionsHeader | php | browscap/browscap | src/Browscap/Writer/CsvWriter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Writer/CsvWriter.php | MIT |
public function renderDivisionHeader(string $division, string $parent = 'DefaultProperties'): void
{
// nothing to do here
} | renders the header for a division
@throws void | renderDivisionHeader | php | browscap/browscap | src/Browscap/Writer/CsvWriter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Writer/CsvWriter.php | MIT |
public function renderSectionHeader(string $sectionName): void
{
// nothing to do here
} | renders the header for a section
@throws void | renderSectionHeader | php | browscap/browscap | src/Browscap/Writer/CsvWriter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Writer/CsvWriter.php | MIT |
public function renderSectionBody(array $section, DataCollection $collection, array $sections = [], string $sectionName = ''): void
{
if ($this->isSilent()) {
return;
}
$division = $collection->getDefaultProperties();
$ua = $division->getUserAgents()[0];
$defaultproperties = $ua->getProperties();
$properties = array_merge(
['PropertyName', 'MasterParent', 'LiteMode', 'Parent'],
array_keys($defaultproperties),
);
$section['PropertyName'] = $sectionName;
$section['MasterParent'] = $this->detectMasterParent($sectionName, $section);
$section['LiteMode'] = (! isset($section['lite']) || ! $section['lite'] ? 'false' : 'true');
$values = [];
foreach ($properties as $property) {
if (! isset($this->outputProperties[$property])) {
$this->outputProperties[$property] = $this->filter->isOutputProperty($property, $this);
}
if (! $this->outputProperties[$property]) {
continue;
}
if (isset($section[$property])) {
$value = $section[$property];
} else {
$value = '';
}
$values[] = $this->formatter->formatPropertyValue($value, $property);
}
fwrite($this->file, implode(',', $values) . PHP_EOL);
} | renders all found useragents into a string
@param array<string, int|string|true> $section
@param array<string, array<string, bool|string>> $sections
@throws InvalidArgumentException
@throws Exception
@throws JsonException | renderSectionBody | php | browscap/browscap | src/Browscap/Writer/CsvWriter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Writer/CsvWriter.php | MIT |
public function renderSectionFooter(string $sectionName = ''): void
{
// nothing to do here
} | renders the footer for a section
@throws void | renderSectionFooter | php | browscap/browscap | src/Browscap/Writer/CsvWriter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Writer/CsvWriter.php | MIT |
public function renderDivisionFooter(): void
{
// nothing to do here
} | renders the footer for a division
@throws void | renderDivisionFooter | php | browscap/browscap | src/Browscap/Writer/CsvWriter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Writer/CsvWriter.php | MIT |
public function renderAllDivisionsFooter(): void
{
// nothing to do here
} | renders the footer for all divisions
@throws void | renderAllDivisionsFooter | php | browscap/browscap | src/Browscap/Writer/CsvWriter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Writer/CsvWriter.php | MIT |
private function detectMasterParent(string $key, array $properties): string
{
$this->logger->debug('check if the element can be marked as "MasterParent"');
if (
in_array($key, ['DefaultProperties', '*'])
|| empty($properties['Parent'])
|| $properties['Parent'] === 'DefaultProperties'
) {
return 'true';
}
return 'false';
} | @param array<string, bool|int|string> $properties
@throws void | detectMasterParent | php | browscap/browscap | src/Browscap/Writer/CsvWriter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Writer/CsvWriter.php | MIT |
public function getType(): string
{
return WriterInterface::TYPE_INI;
} | returns the Type of the writer
@throws void | getType | php | browscap/browscap | src/Browscap/Writer/IniWriter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Writer/IniWriter.php | MIT |
public function close(): void
{
fclose($this->file);
} | closes the Writer and the written File
@throws void | close | php | browscap/browscap | src/Browscap/Writer/IniWriter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Writer/IniWriter.php | MIT |
public function fileStart(): void
{
// nothing to do here
} | Generates a start sequence for the output file
@throws void | fileStart | php | browscap/browscap | src/Browscap/Writer/IniWriter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Writer/IniWriter.php | MIT |
public function fileEnd(): void
{
// nothing to do here
} | Generates a end sequence for the output file
@throws void | fileEnd | php | browscap/browscap | src/Browscap/Writer/IniWriter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Writer/IniWriter.php | MIT |
public function renderHeader(array $comments = []): void
{
if ($this->isSilent()) {
return;
}
$this->logger->debug('rendering comments');
foreach ($comments as $comment) {
fwrite($this->file, ';;; ' . $comment . PHP_EOL);
}
fwrite($this->file, PHP_EOL);
} | Generate the header
@param array<string> $comments
@throws void | renderHeader | php | browscap/browscap | src/Browscap/Writer/IniWriter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Writer/IniWriter.php | MIT |
public function renderVersion(array $versionData = []): void
{
if ($this->isSilent()) {
return;
}
$this->logger->debug('rendering version information');
$this->renderDivisionHeader('Browscap Version');
fwrite($this->file, '[GJK_Browscap_Version]' . PHP_EOL);
if (! isset($versionData['version'])) {
$versionData['version'] = '0';
}
if (! isset($versionData['released'])) {
$versionData['released'] = '';
}
if (! isset($versionData['format'])) {
$versionData['format'] = '';
}
if (! isset($versionData['type'])) {
$versionData['type'] = '';
}
fwrite($this->file, 'Version=' . $versionData['version'] . PHP_EOL);
fwrite($this->file, 'Released=' . $versionData['released'] . PHP_EOL);
fwrite($this->file, 'Format=' . $versionData['format'] . PHP_EOL);
fwrite($this->file, 'Type=' . $versionData['type'] . PHP_EOL . PHP_EOL);
} | renders the version information
@param array<string> $versionData
@throws void | renderVersion | php | browscap/browscap | src/Browscap/Writer/IniWriter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Writer/IniWriter.php | MIT |
public function renderAllDivisionsHeader(DataCollection $collection): void
{
// nothing to do here
} | renders the header for all divisions
@throws void | renderAllDivisionsHeader | php | browscap/browscap | src/Browscap/Writer/IniWriter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Writer/IniWriter.php | MIT |
public function renderDivisionHeader(string $division, string $parent = 'DefaultProperties'): void
{
if ($this->isSilent() || $parent !== 'DefaultProperties') {
return;
}
fwrite($this->file, ';;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ' . $division . PHP_EOL . PHP_EOL);
} | renders the header for a division
@throws void | renderDivisionHeader | php | browscap/browscap | src/Browscap/Writer/IniWriter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Writer/IniWriter.php | MIT |
public function renderSectionHeader(string $sectionName): void
{
if ($this->isSilent()) {
return;
}
fwrite($this->file, '[' . $sectionName . ']' . PHP_EOL);
} | renders the header for a section
@throws void | renderSectionHeader | php | browscap/browscap | src/Browscap/Writer/IniWriter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Writer/IniWriter.php | MIT |
public function renderSectionBody(array $section, DataCollection $collection, array $sections = [], string $sectionName = ''): void
{
if ($this->isSilent()) {
return;
}
$division = $collection->getDefaultProperties();
$ua = $division->getUserAgents()[0];
$defaultproperties = $ua->getProperties();
$properties = array_merge(['Parent'], array_keys($defaultproperties));
foreach ($defaultproperties as $propertyName => $propertyValue) {
if (is_bool($propertyValue)) {
$defaultproperties[$propertyName] = $propertyValue;
} else {
$defaultproperties[$propertyName] = $this->trimProperty->trim((string) $propertyValue);
}
}
foreach ($properties as $property) {
if (! isset($section[$property])) {
continue;
}
if (! isset($this->outputProperties[$property])) {
$this->outputProperties[$property] = $this->filter->isOutputProperty($property, $this);
}
if (! $this->outputProperties[$property]) {
continue;
}
if (isset($section['Parent']) && $property !== 'Parent') {
if (
$section['Parent'] === 'DefaultProperties'
|| ! isset($sections[$section['Parent']])
) {
if (
isset($defaultproperties[$property])
&& $defaultproperties[$property] === $section[$property]
) {
continue;
}
} else {
$parentProperties = $sections[$section['Parent']];
if (
isset($parentProperties[$property])
&& $parentProperties[$property] === $section[$property]
) {
continue;
}
}
}
fwrite(
$this->file,
$this->formatter->formatPropertyName($property)
. '=' . $this->formatter->formatPropertyValue($section[$property], $property) . PHP_EOL,
);
}
} | renders all found useragents into a string
@param array<string, int|string|true> $section
@param array<string, array<string, bool|string>> $sections
@throws InvalidArgumentException
@throws Exception
@throws JsonException | renderSectionBody | php | browscap/browscap | src/Browscap/Writer/IniWriter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Writer/IniWriter.php | MIT |
public function renderSectionFooter(string $sectionName = ''): void
{
if ($this->isSilent()) {
return;
}
fwrite($this->file, PHP_EOL);
} | renders the footer for a section
@throws void | renderSectionFooter | php | browscap/browscap | src/Browscap/Writer/IniWriter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Writer/IniWriter.php | MIT |
public function renderDivisionFooter(): void
{
// nothing to do here
} | renders the footer for a division
@throws void | renderDivisionFooter | php | browscap/browscap | src/Browscap/Writer/IniWriter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Writer/IniWriter.php | MIT |
public function renderAllDivisionsFooter(): void
{
// nothing to do here
} | renders the footer for all divisions
@throws void | renderAllDivisionsFooter | php | browscap/browscap | src/Browscap/Writer/IniWriter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Writer/IniWriter.php | MIT |
public function getType(): string
{
return WriterInterface::TYPE_JSON;
} | returns the Type of the writer
@throws void | getType | php | browscap/browscap | src/Browscap/Writer/JsonWriter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Writer/JsonWriter.php | MIT |
public function close(): void
{
fclose($this->file);
} | closes the Writer and the written File
@throws void | close | php | browscap/browscap | src/Browscap/Writer/JsonWriter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Writer/JsonWriter.php | MIT |
public function fileStart(): void
{
if ($this->isSilent()) {
return;
}
fwrite($this->file, '{' . PHP_EOL);
} | Generates a start sequence for the output file
@throws void | fileStart | php | browscap/browscap | src/Browscap/Writer/JsonWriter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Writer/JsonWriter.php | MIT |
public function fileEnd(): void
{
if ($this->isSilent()) {
return;
}
fwrite($this->file, '}' . PHP_EOL);
} | Generates a end sequence for the output file
@throws void | fileEnd | php | browscap/browscap | src/Browscap/Writer/JsonWriter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Writer/JsonWriter.php | MIT |
public function renderHeader(array $comments = []): void
{
if ($this->isSilent()) {
return;
}
$this->logger->debug('rendering comments');
fwrite($this->file, ' "comments": [' . PHP_EOL);
foreach ($comments as $i => $text) {
fwrite($this->file, ' ' . json_encode($text, JSON_THROW_ON_ERROR));
if ($i < count($comments) - 1) {
fwrite($this->file, ',');
}
fwrite($this->file, PHP_EOL);
}
fwrite($this->file, ' ],' . PHP_EOL);
} | Generate the header
@param array<string> $comments
@throws JsonException | renderHeader | php | browscap/browscap | src/Browscap/Writer/JsonWriter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Writer/JsonWriter.php | MIT |
public function renderVersion(array $versionData = []): void
{
if ($this->isSilent()) {
return;
}
$this->logger->debug('rendering version information');
fwrite($this->file, ' "GJK_Browscap_Version": {' . PHP_EOL);
if (! isset($versionData['version'])) {
$versionData['version'] = '0';
}
if (! isset($versionData['released'])) {
$versionData['released'] = '';
}
fwrite($this->file, ' "Version": ' . json_encode($versionData['version'], JSON_THROW_ON_ERROR) . ',' . PHP_EOL);
fwrite($this->file, ' "Released": ' . json_encode($versionData['released'], JSON_THROW_ON_ERROR) . '' . PHP_EOL);
fwrite($this->file, ' },' . PHP_EOL);
} | renders the version information
@param array<string> $versionData
@throws JsonException | renderVersion | php | browscap/browscap | src/Browscap/Writer/JsonWriter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Writer/JsonWriter.php | MIT |
public function renderAllDivisionsHeader(DataCollection $collection): void
{
// nothing to do here
} | renders the header for all divisions
@throws void | renderAllDivisionsHeader | php | browscap/browscap | src/Browscap/Writer/JsonWriter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Writer/JsonWriter.php | MIT |
public function renderDivisionHeader(string $division, string $parent = 'DefaultProperties'): void
{
// nothing to do here
} | renders the header for a division
@throws void | renderDivisionHeader | php | browscap/browscap | src/Browscap/Writer/JsonWriter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Writer/JsonWriter.php | MIT |
public function renderSectionHeader(string $sectionName): void
{
if ($this->isSilent()) {
return;
}
fwrite($this->file, ' ' . $this->formatter->formatPropertyName($sectionName) . ': ');
} | renders the header for a section
@throws JsonException | renderSectionHeader | php | browscap/browscap | src/Browscap/Writer/JsonWriter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Writer/JsonWriter.php | MIT |
public function renderSectionBody(array $section, DataCollection $collection, array $sections = [], string $sectionName = ''): void
{
if ($this->isSilent()) {
return;
}
$division = $collection->getDefaultProperties();
$ua = $division->getUserAgents()[0];
$defaultproperties = $ua->getProperties();
$properties = array_merge(['Parent'], array_keys($defaultproperties));
foreach ($defaultproperties as $propertyName => $propertyValue) {
if (is_bool($propertyValue)) {
$defaultproperties[$propertyName] = $propertyValue;
} else {
$defaultproperties[$propertyName] = $this->trimProperty->trim((string) $propertyValue);
}
}
$propertiesToOutput = [];
foreach ($properties as $property) {
if (! isset($section[$property])) {
continue;
}
if (! isset($this->outputProperties[$property])) {
$this->outputProperties[$property] = $this->filter->isOutputProperty($property, $this);
}
if (! $this->outputProperties[$property]) {
continue;
}
if (isset($section['Parent']) && $property !== 'Parent') {
if (
$section['Parent'] === 'DefaultProperties'
|| ! isset($sections[$section['Parent']])
) {
if (
isset($defaultproperties[$property])
&& $defaultproperties[$property] === $section[$property]
) {
continue;
}
} else {
$parentProperties = $sections[$section['Parent']];
if (
isset($parentProperties[$property])
&& $parentProperties[$property] === $section[$property]
) {
continue;
}
}
}
$propertiesToOutput[$property] = $section[$property];
}
fwrite(
$this->file,
$this->formatter->formatPropertyValue(json_encode($propertiesToOutput, JSON_THROW_ON_ERROR), 'Comment'),
);
} | renders all found useragents into a string
@param array<string, int|string|true> $section
@param array<string, array<string, bool|string>> $sections
@throws InvalidArgumentException
@throws Exception
@throws JsonException | renderSectionBody | php | browscap/browscap | src/Browscap/Writer/JsonWriter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Writer/JsonWriter.php | MIT |
public function renderSectionFooter(string $sectionName = ''): void
{
if ($this->isSilent()) {
return;
}
if ($sectionName !== '*') {
fwrite($this->file, ',');
}
fwrite($this->file, PHP_EOL);
} | renders the footer for a section
@throws void | renderSectionFooter | php | browscap/browscap | src/Browscap/Writer/JsonWriter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Writer/JsonWriter.php | MIT |
public function renderDivisionFooter(): void
{
// nothing to do here
} | renders the footer for a division
@throws void | renderDivisionFooter | php | browscap/browscap | src/Browscap/Writer/JsonWriter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Writer/JsonWriter.php | MIT |
public function renderAllDivisionsFooter(): void
{
// nothing to do here
} | renders the footer for all divisions
@throws void | renderAllDivisionsFooter | php | browscap/browscap | src/Browscap/Writer/JsonWriter.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Writer/JsonWriter.php | MIT |
public function addWriter(WriterInterface $writer): void
{
$this->writers[] = $writer;
} | add a new writer to the collection
@throws void | addWriter | php | browscap/browscap | src/Browscap/Writer/WriterCollection.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Writer/WriterCollection.php | MIT |
public function close(): void
{
foreach ($this->writers as $writer) {
$writer->close();
}
} | closes the Writer and the written File
@throws void | close | php | browscap/browscap | src/Browscap/Writer/WriterCollection.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Writer/WriterCollection.php | MIT |
public function fileStart(): void
{
foreach ($this->writers as $writer) {
$writer->fileStart();
}
} | Generates a start sequence for the output file
@throws void | fileStart | php | browscap/browscap | src/Browscap/Writer/WriterCollection.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Writer/WriterCollection.php | MIT |
public function fileEnd(): void
{
foreach ($this->writers as $writer) {
$writer->fileEnd();
}
} | Generates a end sequence for the output file
@throws void | fileEnd | php | browscap/browscap | src/Browscap/Writer/WriterCollection.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Writer/WriterCollection.php | MIT |
public function renderHeader(array $comments = []): void
{
foreach ($this->writers as $writer) {
$writer->renderHeader($comments);
}
} | Generate the header
@param array<string> $comments
@throws JsonException | renderHeader | php | browscap/browscap | src/Browscap/Writer/WriterCollection.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Writer/WriterCollection.php | MIT |
public function renderVersion(string $version, DateTimeImmutable $generationDate, DataCollection $collection): void
{
foreach ($this->writers as $writer) {
$writer->renderVersion(
[
'version' => $version,
'released' => $generationDate->format('r'),
'format' => $writer->getFormatter()->getType(),
'type' => $writer->getFilter()->getType(),
],
);
}
} | renders the version information
@throws JsonException | renderVersion | php | browscap/browscap | src/Browscap/Writer/WriterCollection.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Writer/WriterCollection.php | MIT |
public function renderAllDivisionsHeader(DataCollection $collection): void
{
foreach ($this->writers as $writer) {
$writer->renderAllDivisionsHeader($collection);
}
} | renders the header for all divisions
@throws void | renderAllDivisionsHeader | php | browscap/browscap | src/Browscap/Writer/WriterCollection.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Writer/WriterCollection.php | MIT |
public function renderDivisionHeader(string $division, string $parent = 'DefaultProperties'): void
{
foreach ($this->writers as $writer) {
$writer->renderDivisionHeader($division, $parent);
}
} | renders the header for a division
@throws void | renderDivisionHeader | php | browscap/browscap | src/Browscap/Writer/WriterCollection.php | https://github.com/browscap/browscap/blob/master/src/Browscap/Writer/WriterCollection.php | MIT |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.