/** * {@inheritDoc} */ public function extractAttributes($html, array $options) { $Document = $this->_document($html); $options = Hash::normalize($options, []); $data = []; foreach ($options as $name => $required) { $tags = $Document->getElementsByTagName($name); $required = Hash::normalize((array) $required, ''); $data[$name] = []; foreach ($tags as $Tag) { if ($Tag->hasAttributes()) { $attributes = $this->_extractAttributesFromTag($Tag, $required); if (!empty($attributes)) { $data[$name][] = $attributes; } } } } return $data; }
/** * */ public function testNormalize() { $data = Hash::normalize(['one', 'two' => 'three', 'four'], 'default'); $this->assertEquals(['one' => 'default', 'two' => 'three', 'four' => 'default'], $data); }