85 lines
1.7 KiB
PHP
Raw Normal View History

2012-05-06 18:25:40 +02:00
<?php
/**
* PHPWord
2012-05-06 18:25:40 +02:00
*
2014-03-27 23:55:06 +07:00
* @link https://github.com/PHPOffice/PHPWord
* @copyright 2014 PHPWord
* @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL
2012-05-06 18:25:40 +02:00
*/
namespace PhpOffice\PhpWord\Element\Table;
2013-12-16 06:40:30 -05:00
use PhpOffice\PhpWord\Container\Container;
use PhpOffice\PhpWord\Style\Cell as CellStyle;
/**
* Table cell element
*/
class Cell extends Container
{
2013-12-16 06:40:30 -05:00
/**
* Cell width
2013-12-16 06:40:30 -05:00
*
* @var int
*/
private $width = null;
2013-12-16 06:40:30 -05:00
/**
* Cell style
2013-12-16 06:40:30 -05:00
*
* @var CellStyle
2013-12-16 06:40:30 -05:00
*/
private $cellStyle;
2013-12-16 06:40:30 -05:00
/**
* Create new instance
2013-12-16 06:40:30 -05:00
*
* @param string $parentType section|header|footer
* @param int $parentId
2013-12-16 06:40:30 -05:00
* @param int $width
* @param array|CellStyle $style
2013-12-16 06:40:30 -05:00
*/
public function __construct($parentType, $parentId, $width = null, $style = null)
2013-12-16 06:40:30 -05:00
{
$this->containerType = 'cell';
$this->parentContainer = $parentType;
$this->parentContainerId = $parentId;
$this->width = $width;
$this->cellStyle = new CellStyle();
2013-12-16 06:40:30 -05:00
if (!is_null($style)) {
if (is_array($style)) {
foreach ($style as $key => $value) {
if (substr($key, 0, 1) != '_') {
$key = '_' . $key;
}
$this->cellStyle->setStyleValue($key, $value);
2013-12-16 06:40:30 -05:00
}
} else {
$this->cellStyle = $style;
2013-12-16 06:40:30 -05:00
}
}
}
/**
* Get cell style
2013-12-16 06:40:30 -05:00
*
* @return CellStyle
2013-12-16 06:40:30 -05:00
*/
public function getStyle()
{
return $this->cellStyle;
2013-12-16 06:40:30 -05:00
}
/**
* Get cell width
2013-12-16 06:40:30 -05:00
*
* @return int
*/
public function getWidth()
{
return $this->width;
2013-12-16 06:40:30 -05:00
}
}