/** * @dataProvider getLineStyleValues */ public function testLineValueHandler($input, $expectation, $string = '') { $value = new ezcDocumentPcssStyleLineValue(); $value->parse($input); $this->assertEquals($expectation, $value->value, 'Invalid style style value read.', 0.01); $this->assertEquals($string, (string) $value, 'Invalid style style string serialization.'); }
/** * Parse value string representation. * * Parse the string representation of the value into a usable * representation. * * @param string $value * @return ezcDocumentPcssStyleValue */ public function parse($value) { $widthParser = new ezcDocumentPcssStyleMeasureValue(); $styleParser = new ezcDocumentPcssStyleLineValue(); $colorParser = new ezcDocumentPcssStyleColorValue(); $regexp = '(^\\s*' . '(?:(?P<width>' . $widthParser->getRegularExpression() . ')\\s*)?' . '(?:(?P<style>' . $styleParser->getRegularExpression() . ')\\s*)?' . '(?:(?P<color>' . $colorParser->getRegularExpression() . ')\\s*)?' . '\\s*$)'; if (!preg_match($regexp, $value, $match)) { throw new ezcDocumentParserException(E_PARSE, "Invalid border specification: " . $value); } $this->value = $this->defaultValue; if (isset($match['width']) && !empty($match['width'])) { $this->value['width'] = $widthParser->parse($match['width'])->value; } if (isset($match['style']) && !empty($match['style'])) { $this->value['style'] = $styleParser->parse($match['style'])->value; } if (isset($match['color']) && !empty($match['color'])) { $this->value['color'] = $colorParser->parse($match['color'])->value; } return $this; }