From 3c8796043b4622603c7a94ce889fd40c148fea43 Mon Sep 17 00:00:00 2001 From: madflow Date: Thu, 30 Mar 2017 10:45:52 +0200 Subject: [PATCH] first batch of changes #182 --- src/Spout/Writer/Common/Cell.php | 22 +++++++++++++------- src/Spout/Writer/ODS/Internal/Worksheet.php | 2 +- src/Spout/Writer/XLSX/Internal/Worksheet.php | 2 +- 3 files changed, 16 insertions(+), 10 deletions(-) diff --git a/src/Spout/Writer/Common/Cell.php b/src/Spout/Writer/Common/Cell.php index e637274..4781fbe 100644 --- a/src/Spout/Writer/Common/Cell.php +++ b/src/Spout/Writer/Common/Cell.php @@ -4,6 +4,11 @@ namespace Box\Spout\Writer\Common; use Box\Spout\Writer\Common\Helper\CellHelper; +/** + * Class Cell + * + * @package Box\Spout\Writer\Common + */ class Cell { /** @@ -18,13 +23,14 @@ class Cell /** * Formula cell type + * Not used at the moment */ const TYPE_FORMULA = 2; /** - * Blank cell type + * Empty cell type */ - const TYPE_BLANK = 3; + const TYPE_EMPTY = 3; /** * Boolean cell type @@ -38,20 +44,19 @@ class Cell /** * The value of this cell - * @var null | mixed + * @var mixed|null */ protected $value = null; /** * The cell type - * @var null + * @var int */ protected $type = null; /** * Cell constructor. * @param $value mixed - * @param $comment string */ public function __construct($value) { @@ -92,7 +97,7 @@ class Cell if (CellHelper::isBoolean($value)) { return self::TYPE_BOOLEAN; } elseif (CellHelper::isEmpty($value)) { - return self::TYPE_BLANK; + return self::TYPE_EMPTY; } elseif (CellHelper::isNumeric($this->getValue())) { return self::TYPE_NUMERIC; } elseif (CellHelper::isNonEmptyString($value)) { @@ -113,12 +118,13 @@ class Cell /** * @return bool */ - public function isBlank() + public function isEmpty() { - return $this->type === self::TYPE_BLANK; + return $this->type === self::TYPE_EMPTY; } /** + * Not used at the moment * @return bool */ public function isFormula() diff --git a/src/Spout/Writer/ODS/Internal/Worksheet.php b/src/Spout/Writer/ODS/Internal/Worksheet.php index 9e64326..39dbcf6 100644 --- a/src/Spout/Writer/ODS/Internal/Worksheet.php +++ b/src/Spout/Writer/ODS/Internal/Worksheet.php @@ -215,7 +215,7 @@ class Worksheet implements WorksheetInterface $data .= ' office:value-type="float" calcext:value-type="float" office:value="' . $cell->getValue() . '">'; $data .= '' . $cell->getValue() . ''; $data .= ''; - } else if ($cell->isBlank()) { + } else if ($cell->isEmpty()) { $data .= '/>'; } else { throw new InvalidArgumentException('Trying to add a value with an unsupported type: ' . gettype($cell->getValue())); diff --git a/src/Spout/Writer/XLSX/Internal/Worksheet.php b/src/Spout/Writer/XLSX/Internal/Worksheet.php index 7150ce9..cef4309 100644 --- a/src/Spout/Writer/XLSX/Internal/Worksheet.php +++ b/src/Spout/Writer/XLSX/Internal/Worksheet.php @@ -226,7 +226,7 @@ EOD; $cellXML .= ' t="b">' . intval($cell->getValue()) . ''; } else if ($cell->isNumeric()) { $cellXML .= '>' . $cell->getValue() . ''; - } else if ($cell->isBlank()) { + } else if ($cell->isEmpty()) { if ($this->styleHelper->shouldApplyStyleOnEmptyCell($styleId)) { $cellXML .= '/>'; } else {