/**
* renders all found useragents into a string
*
* @param string[] $section
* @param \Browscap\Data\DataCollection $collection
* @param array[] $sections
* @param string $sectionName
*
* @throws \InvalidArgumentException
* @return JsonWriter
*/
public function renderSectionBody(array $section, DataCollection $collection, array $sections = [], $sectionName = '')
{
if ($this->isSilent()) {
return $this;
}
$division = $collection->getDefaultProperties();
$ua = $division->getUserAgents();
$defaultproperties = $ua[0]['properties'];
$properties = array_merge(['Parent'], array_keys($defaultproperties));
foreach ($defaultproperties as $propertyName => $propertyValue) {
$defaultproperties[$propertyName] = $this->expander->trimProperty($propertyValue);
}
$propertiesToOutput = [];
foreach ($properties as $property) {
if (!isset($section[$property])) {
continue;
}
if (!isset($this->outputProperties[$property])) {
$this->outputProperties[$property] = $this->getFilter()->isOutputProperty($property, $this);
}
if (!$this->outputProperties[$property]) {
continue;
}
if (isset($section['Parent']) && 'Parent' !== $property) {
if ('DefaultProperties' === $section['Parent'] || !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];
}
fputs($this->file, $this->getFormatter()->formatPropertyValue(json_encode($propertiesToOutput), 'Comment'));
return $this;
}