*/ class BorderHelper { /** * Width mappings * * @var array */ protected static $widthMap = [ Border::WIDTH_THIN => '0.75pt', Border::WIDTH_MEDIUM => '1.75pt', Border::WIDTH_THICK => '2.5pt', ]; /** * Style mapping * * @var array */ protected static $styleMap = [ Border::STYLE_SOLID => 'solid', Border::STYLE_DASHED => 'dashed', Border::STYLE_DOTTED => 'dotted', Border::STYLE_DOUBLE => 'double', ]; /** * @param BorderPart $borderPart * @return string */ public static function serializeBorderPart(BorderPart $borderPart) { $definition = 'fo:border-%s="%s"'; if ($borderPart->getStyle() === Border::STYLE_NONE) { $borderPartDefinition = sprintf($definition, $borderPart->getName(), 'none'); } else { $attributes = [ self::$widthMap[$borderPart->getWidth()], self::$styleMap[$borderPart->getStyle()], '#' . $borderPart->getColor(), ]; $borderPartDefinition = sprintf($definition, $borderPart->getName(), implode(' ', $attributes)); } return $borderPartDefinition; } }