Browscap\Writer\XmlWriter::renderSectionBody PHP Method

renderSectionBody() public method

renders all found useragents into a string
public renderSectionBody ( array $section, DataCollection $collection, array $sections = [], string $sectionName = '' ) : XmlWriter
$section array
$collection Browscap\Data\DataCollection
$sections array
$sectionName string
return XmlWriter
    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 ($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;
            }
            fputs($this->file, '<item name="' . $this->getFormatter()->formatPropertyName($property) . '" value="' . $this->getFormatter()->formatPropertyValue($section[$property], $property) . '"/>' . PHP_EOL);
        }
        return $this;
    }

Usage Example

Example #1
0
 /**
  * tests rendering the body of one section
  *
  * @group writer
  * @group sourcetest
  */
 public function testRenderSectionBodyIfSilent()
 {
     $this->object->setSilent(true);
     $section = array('Test' => 1, 'isTest' => true, 'abc' => 'bcd');
     $mockCollection = $this->getMock('\\Browscap\\Data\\DataCollection', array(), array(), '', false);
     self::assertSame($this->object, $this->object->renderSectionBody($section, $mockCollection));
     self::assertSame('', file_get_contents($this->file));
 }
All Usage Examples Of Browscap\Writer\XmlWriter::renderSectionBody