for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
/**
* @author neun
* @since 2016-07-03
*/
namespace OneSheet;
* Class Style
* @package OneSheet
class Style
{
* @var int
private $size = 11;
* @var string
private $color = '000000';
private $name = 'Calibri';
private $bold;
private $italic;
private $underline;
private $fill;
* @return string
public function getFontXml()
return sprintf('<font><sz val="%s"/><color rgb="%s"/><name val="%s"/>%s%s%s</font>',
$this->size, $this->color, $this->name, $this->bold, $this->italic, $this->underline
);
}
public function getFillXml()
if (!$this->fill) {
return '<fill><patternFill patternType="none"/></fill>';
return '<fill><patternFill patternType="solid"><fgColor rgb="' . $this->fill . '"/></patternFill></fill>';
* Set font size.
*
* @param int $size
* @return Style
public function size($size)
$this->size = $size;
return $this;
* Set font color.
* @param string $color
public function color($color)
$this->color = strtoupper($color);
* Set font name.
* @param string $name
public function name($name)
$this->name = $name;
* Make font bold.
public function bold()
$this->bold = '<b/>';
* Make font italic.
public function italic()
$this->italic = '<i/>';
* Underline the font text.
public function underline()
$this->underline = '<u/>';
* Set the cell fill/background color.
* @param string $fill
public function fill($fill)
$this->fill = strtoupper($fill);