Box\Spout\Writer\Style\Style::mergeWith PHP Method

mergeWith() public method

Merges the current style with the given style, using the given style as a base. This means that: - if current style and base style both have property A set, use current style property's value - if current style has property A set but base style does not, use current style property's value - if base style has property A set but current style does not, use base style property's value
public mergeWith ( Style $baseStyle ) : Style
$baseStyle Style
return Style New style corresponding to the merge of the 2 styles
    public function mergeWith($baseStyle)
    {
        $mergedStyle = clone $this;
        $this->mergeFontStyles($mergedStyle, $baseStyle);
        $this->mergeOtherFontProperties($mergedStyle, $baseStyle);
        $this->mergeCellProperties($mergedStyle, $baseStyle);
        return $mergedStyle;
    }

Usage Example

Esempio n. 1
0
 /**
  * Sets the style to be applied to the next written rows
  * until it is changed or reset.
  *
  * @param Style\Style $style
  * @return void
  */
 private function setRowStyle($style)
 {
     // Merge given style with the default one to inherit custom properties
     $this->rowStyle = $style->mergeWith($this->defaultRowStyle);
 }