Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 3.9.x will end* 10 May 2021 (12 months).
  • Bug fixes for security issues in 3.9.x will end* 8 May 2023 (36 months).
  • PHP version: minimum PHP 7.2.0 Note: minimum PHP version has increased since Moodle 3.8. PHP 7.3.x and 7.4.x are supported too.
<?php

namespace Box\Spout\Writer\Common\Creator\Style;

use Box\Spout\Common\Entity\Style\Border;
> use Box\Spout\Common\Entity\Style\CellAlignment;
use Box\Spout\Common\Entity\Style\Style;
> use Box\Spout\Common\Exception\InvalidArgumentException;
/** * Class StyleBuilder * Builder to create new styles */ class StyleBuilder { /** @var Style Style to be created */ protected $style; /** * */ public function __construct() { $this->style = new Style(); } /** * Makes the font bold. * * @return StyleBuilder */ public function setFontBold() { $this->style->setFontBold(); return $this; } /** * Makes the font italic. * * @return StyleBuilder */ public function setFontItalic() { $this->style->setFontItalic(); return $this; } /** * Makes the font underlined. * * @return StyleBuilder */ public function setFontUnderline() { $this->style->setFontUnderline(); return $this; } /** * Makes the font struck through. * * @return StyleBuilder */ public function setFontStrikethrough() { $this->style->setFontStrikethrough(); return $this; } /** * Sets the font size. * * @param int $fontSize Font size, in pixels * @return StyleBuilder */ public function setFontSize($fontSize) { $this->style->setFontSize($fontSize); return $this; } /** * Sets the font color. * * @param string $fontColor ARGB color (@see Color) * @return StyleBuilder */ public function setFontColor($fontColor) { $this->style->setFontColor($fontColor); return $this; } /** * Sets the font name. * * @param string $fontName Name of the font to use * @return StyleBuilder */ public function setFontName($fontName) { $this->style->setFontName($fontName); return $this; } /** * Makes the text wrap in the cell if requested * * @param bool $shouldWrap Should the text be wrapped * @return StyleBuilder */ public function setShouldWrapText($shouldWrap = true) { $this->style->setShouldWrapText($shouldWrap); return $this; } /**
> * Sets the cell alignment. * Set a border > * * > * @param string $cellAlignment The cell alignment * @param Border $border > * * @return $this > * @throws InvalidArgumentException If the given cell alignment is not valid */ > * @return StyleBuilder public function setBorder(Border $border) > */ { > public function setCellAlignment($cellAlignment) $this->style->setBorder($border); > { > if (!CellAlignment::isValid($cellAlignment)) { return $this; > throw new InvalidArgumentException('Invalid cell alignment value'); } > } > /** > $this->style->setCellAlignment($cellAlignment); * Sets a background color > * > return $this; * @param string $color ARGB color (@see Color) > } * @return StyleBuilder > */ > /**
public function setBackgroundColor($color) { $this->style->setBackgroundColor($color);
> > return $this; return $this; > } } > > /** /** > * Sets a format * Returns the configured style. The style is cached and can be reused. > * * > * @param string $format Format * @return Style > * @return StyleBuilder */ > * @api public function build() > */ { > public function setFormat($format) return $this->style; > { } > $this->style->setFormat($format);
}