/** * Create new table style * * @param mixed $styleTable * @param mixed $styleFirstRow */ public function __construct($styleTable = null, $styleFirstRow = null) { if (!is_null($styleFirstRow) && is_array($styleFirstRow)) { $this->firstRow = clone $this; unset($this->firstRow->firstRow); unset($this->firstRow->cellMarginBottom); unset($this->firstRow->cellMarginTop); unset($this->firstRow->cellMarginLeft); unset($this->firstRow->cellMarginRight); unset($this->firstRow->borderInsideVColor); unset($this->firstRow->borderInsideVSize); unset($this->firstRow->borderInsideHColor); unset($this->firstRow->borderInsideHSize); foreach ($styleFirstRow as $key => $value) { $this->firstRow->setStyleValue($key, $value); } } if (!is_null($styleTable) && is_array($styleTable)) { foreach ($styleTable as $key => $value) { $this->setStyleValue($key, $value); } } }
/** * Set style values and put it to static style collection * * @param string $styleName * @param Paragraph|Font|Table|Numbering $styleObject * @param array|null $styleValues */ private static function setStyleValues($styleName, $styleObject, $styleValues = null) { if (!array_key_exists($styleName, self::$styles)) { if (!is_null($styleValues) && is_array($styleValues)) { foreach ($styleValues as $key => $value) { $styleObject->setStyleValue($key, $value); } } $styleObject->setStyleName($styleName); $styleObject->setIndex(self::countStyles() + 1); // One based index self::$styles[$styleName] = $styleObject; } }
/** * Set style value for various special value types */ public function testSetStyleValue() { $object = new Table(); $object->setStyleValue('borderSize', 120); $object->setStyleValue('cellMargin', 240); $object->setStyleValue('borderColor', '999999'); $this->assertEquals(array(120, 120, 120, 120, 120, 120), $object->getBorderSize()); $this->assertEquals(array(240, 240, 240, 240), $object->getCellMargin()); $this->assertEquals(array('999999', '999999', '999999', '999999', '999999', '999999'), $object->getBorderColor()); }