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(['PropertyName', 'MasterParent', 'LiteMode', 'Parent'], array_keys($defaultproperties)); $values = []; $section['PropertyName'] = $sectionName; $section['MasterParent'] = $this->detectMasterParent($sectionName, $section); if (in_array($sectionName, ['DefaultProperties', '*'])) { $section['LiteMode'] = 'true'; } else { $section['LiteMode'] = !isset($section['lite']) || !$section['lite'] ? 'false' : 'true'; } foreach ($properties as $property) { if (!isset($this->outputProperties[$property])) { $this->outputProperties[$property] = $this->getFilter()->isOutputProperty($property, $this); } if (!$this->outputProperties[$property]) { continue; } if (isset($section[$property])) { $value = $section[$property]; } else { $value = ''; } $values[] = $this->getFormatter()->formatPropertyValue($value, $property); } fputs($this->file, implode(',', $values) . PHP_EOL); return $this; }
/** * tests rendering the body of one section * * @group writer * @group sourcetest */ public function testRenderSectionBodyIfSilent() { $this->object->setSilent(true); $section = ['Test' => 1, 'isTest' => true, 'abc' => 'bcd']; $collection = $this->createMock(\Browscap\Data\DataCollection::class); self::assertSame($this->object, $this->object->renderSectionBody($section, $collection)); self::assertSame('', file_get_contents($this->file)); }