Sane argument names in the Cell classes

This commit is contained in:
MarkBaker 2020-11-03 19:28:45 +01:00
parent 4ab629ff82
commit b5c2709002
5 changed files with 186 additions and 186 deletions

View File

@ -89,24 +89,24 @@ class Cell
/** /**
* Create a new Cell. * Create a new Cell.
* *
* @param mixed $pValue * @param mixed $value
* @param string $pDataType * @param string $dataType
*/ */
public function __construct($pValue, $pDataType, Worksheet $pSheet) public function __construct($value, $dataType, Worksheet $worksheet)
{ {
// Initialise cell value // Initialise cell value
$this->value = $pValue; $this->value = $value;
// Set worksheet cache // Set worksheet cache
$this->parent = $pSheet->getCellCollection(); $this->parent = $worksheet->getCellCollection();
// Set datatype? // Set datatype?
if ($pDataType !== null) { if ($dataType !== null) {
if ($pDataType == DataType::TYPE_STRING2) { if ($dataType == DataType::TYPE_STRING2) {
$pDataType = DataType::TYPE_STRING; $dataType = DataType::TYPE_STRING;
} }
$this->dataType = $pDataType; $this->dataType = $dataType;
} elseif (!self::getValueBinder()->bindValue($this, $pValue)) { } elseif (!self::getValueBinder()->bindValue($this, $value)) {
throw new Exception('Value could not be bound to cell.'); throw new Exception('Value could not be bound to cell.');
} }
} }
@ -170,13 +170,13 @@ class Cell
* *
* Sets the value for a cell, automatically determining the datatype using the value binder * Sets the value for a cell, automatically determining the datatype using the value binder
* *
* @param mixed $pValue Value * @param mixed $value Value
* *
* @return $this * @return $this
*/ */
public function setValue($pValue) public function setValue($value)
{ {
if (!self::getValueBinder()->bindValue($this, $pValue)) { if (!self::getValueBinder()->bindValue($this, $value)) {
throw new Exception('Value could not be bound to cell.'); throw new Exception('Value could not be bound to cell.');
} }
@ -186,56 +186,56 @@ class Cell
/** /**
* Set the value for a cell, with the explicit data type passed to the method (bypassing any use of the value binder). * Set the value for a cell, with the explicit data type passed to the method (bypassing any use of the value binder).
* *
* @param mixed $pValue Value * @param mixed $value Value
* @param string $pDataType Explicit data type, see DataType::TYPE_* * @param string $dataType Explicit data type, see DataType::TYPE_*
* *
* @return Cell * @return Cell
*/ */
public function setValueExplicit($pValue, $pDataType) public function setValueExplicit($value, $dataType)
{ {
// set the value according to data type // set the value according to data type
switch ($pDataType) { switch ($dataType) {
case DataType::TYPE_NULL: case DataType::TYPE_NULL:
$this->value = $pValue; $this->value = $value;
break; break;
case DataType::TYPE_STRING2: case DataType::TYPE_STRING2:
$pDataType = DataType::TYPE_STRING; $dataType = DataType::TYPE_STRING;
// no break // no break
case DataType::TYPE_STRING: case DataType::TYPE_STRING:
// Synonym for string // Synonym for string
case DataType::TYPE_INLINE: case DataType::TYPE_INLINE:
// Rich text // Rich text
$this->value = DataType::checkString($pValue); $this->value = DataType::checkString($value);
break; break;
case DataType::TYPE_NUMERIC: case DataType::TYPE_NUMERIC:
if (is_string($pValue) && !is_numeric($pValue)) { if (is_string($value) && !is_numeric($value)) {
throw new Exception('Invalid numeric value for datatype Numeric'); throw new Exception('Invalid numeric value for datatype Numeric');
} }
$this->value = 0 + $pValue; $this->value = 0 + $value;
break; break;
case DataType::TYPE_FORMULA: case DataType::TYPE_FORMULA:
$this->value = (string) $pValue; $this->value = (string) $value;
break; break;
case DataType::TYPE_BOOL: case DataType::TYPE_BOOL:
$this->value = (bool) $pValue; $this->value = (bool) $value;
break; break;
case DataType::TYPE_ERROR: case DataType::TYPE_ERROR:
$this->value = DataType::checkErrorCode($pValue); $this->value = DataType::checkErrorCode($value);
break; break;
default: default:
throw new Exception('Invalid datatype: ' . $pDataType); throw new Exception('Invalid datatype: ' . $dataType);
break; break;
} }
// set the datatype // set the datatype
$this->dataType = $pDataType; $this->dataType = $dataType;
return $this->updateInCollection(); return $this->updateInCollection();
} }
@ -289,14 +289,14 @@ class Cell
/** /**
* Set old calculated value (cached). * Set old calculated value (cached).
* *
* @param mixed $pValue Value * @param mixed $originalValue Value
* *
* @return Cell * @return Cell
*/ */
public function setCalculatedValue($pValue) public function setCalculatedValue($originalValue)
{ {
if ($pValue !== null) { if ($originalValue !== null) {
$this->calculatedValue = (is_numeric($pValue)) ? (float) $pValue : $pValue; $this->calculatedValue = (is_numeric($originalValue)) ? (float) $originalValue : $originalValue;
} }
return $this->updateInCollection(); return $this->updateInCollection();
@ -330,16 +330,16 @@ class Cell
/** /**
* Set cell data type. * Set cell data type.
* *
* @param string $pDataType see DataType::TYPE_* * @param string $dataType see DataType::TYPE_*
* *
* @return Cell * @return Cell
*/ */
public function setDataType($pDataType) public function setDataType($dataType)
{ {
if ($pDataType == DataType::TYPE_STRING2) { if ($dataType == DataType::TYPE_STRING2) {
$pDataType = DataType::TYPE_STRING; $dataType = DataType::TYPE_STRING;
} }
$this->dataType = $pDataType; $this->dataType = $dataType;
return $this->updateInCollection(); return $this->updateInCollection();
} }
@ -385,17 +385,17 @@ class Cell
/** /**
* Set Data validation rules. * Set Data validation rules.
* *
* @param DataValidation $pDataValidation * @param DataValidation $dataValidation
* *
* @return Cell * @return Cell
*/ */
public function setDataValidation(?DataValidation $pDataValidation = null) public function setDataValidation(?DataValidation $dataValidation = null)
{ {
if (!isset($this->parent)) { if (!isset($this->parent)) {
throw new Exception('Cannot set data validation for cell that is not bound to a worksheet'); throw new Exception('Cannot set data validation for cell that is not bound to a worksheet');
} }
$this->getWorksheet()->setDataValidation($this->getCoordinate(), $pDataValidation); $this->getWorksheet()->setDataValidation($this->getCoordinate(), $dataValidation);
return $this->updateInCollection(); return $this->updateInCollection();
} }
@ -443,17 +443,17 @@ class Cell
/** /**
* Set Hyperlink. * Set Hyperlink.
* *
* @param Hyperlink $pHyperlink * @param Hyperlink $hyperlink
* *
* @return Cell * @return Cell
*/ */
public function setHyperlink(?Hyperlink $pHyperlink = null) public function setHyperlink(?Hyperlink $hyperlink = null)
{ {
if (!isset($this->parent)) { if (!isset($this->parent)) {
throw new Exception('Cannot set hyperlink for cell that is not bound to a worksheet'); throw new Exception('Cannot set hyperlink for cell that is not bound to a worksheet');
} }
$this->getWorksheet()->setHyperlink($this->getCoordinate(), $pHyperlink); $this->getWorksheet()->setHyperlink($this->getCoordinate(), $hyperlink);
return $this->updateInCollection(); return $this->updateInCollection();
} }
@ -547,13 +547,13 @@ class Cell
/** /**
* Is cell in a specific range? * Is cell in a specific range?
* *
* @param string $pRange Cell range (e.g. A1:A1) * @param string $range Cell range (e.g. A1:A1)
* *
* @return bool * @return bool
*/ */
public function isInRange($pRange) public function isInRange($range)
{ {
[$rangeStart, $rangeEnd] = Coordinate::rangeBoundaries($pRange); [$rangeStart, $rangeEnd] = Coordinate::rangeBoundaries($range);
// Translate properties // Translate properties
$myColumn = Coordinate::columnIndexFromString($this->getColumn()); $myColumn = Coordinate::columnIndexFromString($this->getColumn());
@ -635,13 +635,13 @@ class Cell
/** /**
* Set index to cellXf. * Set index to cellXf.
* *
* @param int $pValue * @param int $indexValue
* *
* @return Cell * @return Cell
*/ */
public function setXfIndex($pValue) public function setXfIndex($indexValue)
{ {
$this->xfIndex = $pValue; $this->xfIndex = $indexValue;
return $this->updateInCollection(); return $this->updateInCollection();
} }
@ -649,13 +649,13 @@ class Cell
/** /**
* Set the formula attributes. * Set the formula attributes.
* *
* @param mixed $pAttributes * @param mixed $attributes
* *
* @return $this * @return $this
*/ */
public function setFormulaAttributes($pAttributes) public function setFormulaAttributes($attributes)
{ {
$this->formulaAttributes = $pAttributes; $this->formulaAttributes = $attributes;
return $this; return $this;
} }

View File

@ -23,86 +23,86 @@ abstract class Coordinate
/** /**
* Coordinate from string. * Coordinate from string.
* *
* @param string $pCoordinateString eg: 'A1' * @param string $cellAddress eg: 'A1'
* *
* @return string[] Array containing column and row (indexes 0 and 1) * @return string[] Array containing column and row (indexes 0 and 1)
*/ */
public static function coordinateFromString($pCoordinateString) public static function coordinateFromString($cellAddress)
{ {
if (preg_match('/^([$]?[A-Z]{1,3})([$]?\\d{1,7})$/', $pCoordinateString, $matches)) { if (preg_match('/^([$]?[A-Z]{1,3})([$]?\\d{1,7})$/', $cellAddress, $matches)) {
return [$matches[1], $matches[2]]; return [$matches[1], $matches[2]];
} elseif (self::coordinateIsRange($pCoordinateString)) { } elseif (self::coordinateIsRange($cellAddress)) {
throw new Exception('Cell coordinate string can not be a range of cells'); throw new Exception('Cell coordinate string can not be a range of cells');
} elseif ($pCoordinateString == '') { } elseif ($cellAddress == '') {
throw new Exception('Cell coordinate can not be zero-length string'); throw new Exception('Cell coordinate can not be zero-length string');
} }
throw new Exception('Invalid cell coordinate ' . $pCoordinateString); throw new Exception('Invalid cell coordinate ' . $cellAddress);
} }
/** /**
* Checks if a coordinate represents a range of cells. * Checks if a Cell Address represents a range of cells.
* *
* @param string $coord eg: 'A1' or 'A1:A2' or 'A1:A2,C1:C2' * @param string $cellAddress eg: 'A1' or 'A1:A2' or 'A1:A2,C1:C2'
* *
* @return bool Whether the coordinate represents a range of cells * @return bool Whether the coordinate represents a range of cells
*/ */
public static function coordinateIsRange($coord) public static function coordinateIsRange($cellAddress)
{ {
return (strpos($coord, ':') !== false) || (strpos($coord, ',') !== false); return (strpos($cellAddress, ':') !== false) || (strpos($cellAddress, ',') !== false);
} }
/** /**
* Make string row, column or cell coordinate absolute. * Make string row, column or cell coordinate absolute.
* *
* @param string $pCoordinateString e.g. 'A' or '1' or 'A1' * @param string $cellAddress e.g. 'A' or '1' or 'A1'
* Note that this value can be a row or column reference as well as a cell reference * Note that this value can be a row or column reference as well as a cell reference
* *
* @return string Absolute coordinate e.g. '$A' or '$1' or '$A$1' * @return string Absolute coordinate e.g. '$A' or '$1' or '$A$1'
*/ */
public static function absoluteReference($pCoordinateString) public static function absoluteReference($cellAddress)
{ {
if (self::coordinateIsRange($pCoordinateString)) { if (self::coordinateIsRange($cellAddress)) {
throw new Exception('Cell coordinate string can not be a range of cells'); throw new Exception('Cell coordinate string can not be a range of cells');
} }
// Split out any worksheet name from the reference // Split out any worksheet name from the reference
[$worksheet, $pCoordinateString] = Worksheet::extractSheetTitle($pCoordinateString, true); [$worksheet, $cellAddress] = Worksheet::extractSheetTitle($cellAddress, true);
if ($worksheet > '') { if ($worksheet > '') {
$worksheet .= '!'; $worksheet .= '!';
} }
// Create absolute coordinate // Create absolute coordinate
if (ctype_digit($pCoordinateString)) { if (ctype_digit($cellAddress)) {
return $worksheet . '$' . $pCoordinateString; return $worksheet . '$' . $cellAddress;
} elseif (ctype_alpha($pCoordinateString)) { } elseif (ctype_alpha($cellAddress)) {
return $worksheet . '$' . strtoupper($pCoordinateString); return $worksheet . '$' . strtoupper($cellAddress);
} }
return $worksheet . self::absoluteCoordinate($pCoordinateString); return $worksheet . self::absoluteCoordinate($cellAddress);
} }
/** /**
* Make string coordinate absolute. * Make string coordinate absolute.
* *
* @param string $pCoordinateString e.g. 'A1' * @param string $cellAddress e.g. 'A1'
* *
* @return string Absolute coordinate e.g. '$A$1' * @return string Absolute coordinate e.g. '$A$1'
*/ */
public static function absoluteCoordinate($pCoordinateString) public static function absoluteCoordinate($cellAddress)
{ {
if (self::coordinateIsRange($pCoordinateString)) { if (self::coordinateIsRange($cellAddress)) {
throw new Exception('Cell coordinate string can not be a range of cells'); throw new Exception('Cell coordinate string can not be a range of cells');
} }
// Split out any worksheet name from the coordinate // Split out any worksheet name from the coordinate
[$worksheet, $pCoordinateString] = Worksheet::extractSheetTitle($pCoordinateString, true); [$worksheet, $cellAddress] = Worksheet::extractSheetTitle($cellAddress, true);
if ($worksheet > '') { if ($worksheet > '') {
$worksheet .= '!'; $worksheet .= '!';
} }
// Create absolute coordinate // Create absolute coordinate
[$column, $row] = self::coordinateFromString($pCoordinateString); [$column, $row] = self::coordinateFromString($cellAddress);
$column = ltrim($column, '$'); $column = ltrim($column, '$');
$row = ltrim($row, '$'); $row = ltrim($row, '$');
@ -112,20 +112,20 @@ abstract class Coordinate
/** /**
* Split range into coordinate strings. * Split range into coordinate strings.
* *
* @param string $pRange e.g. 'B4:D9' or 'B4:D9,H2:O11' or 'B4' * @param string $range e.g. 'B4:D9' or 'B4:D9,H2:O11' or 'B4'
* *
* @return array Array containing one or more arrays containing one or two coordinate strings * @return array Array containing one or more arrays containing one or two coordinate strings
* e.g. ['B4','D9'] or [['B4','D9'], ['H2','O11']] * e.g. ['B4','D9'] or [['B4','D9'], ['H2','O11']]
* or ['B4'] * or ['B4']
*/ */
public static function splitRange($pRange) public static function splitRange($range)
{ {
// Ensure $pRange is a valid range // Ensure $pRange is a valid range
if (empty($pRange)) { if (empty($range)) {
$pRange = self::DEFAULT_RANGE; $range = self::DEFAULT_RANGE;
} }
$exploded = explode(',', $pRange); $exploded = explode(',', $range);
$counter = count($exploded); $counter = count($exploded);
for ($i = 0; $i < $counter; ++$i) { for ($i = 0; $i < $counter; ++$i) {
$exploded[$i] = explode(':', $exploded[$i]); $exploded[$i] = explode(':', $exploded[$i]);
@ -137,49 +137,49 @@ abstract class Coordinate
/** /**
* Build range from coordinate strings. * Build range from coordinate strings.
* *
* @param array $pRange Array containg one or more arrays containing one or two coordinate strings * @param array $range Array containg one or more arrays containing one or two coordinate strings
* *
* @return string String representation of $pRange * @return string String representation of $pRange
*/ */
public static function buildRange(array $pRange) public static function buildRange(array $range)
{ {
// Verify range // Verify range
if (empty($pRange) || !is_array($pRange[0])) { if (empty($range) || !is_array($range[0])) {
throw new Exception('Range does not contain any information'); throw new Exception('Range does not contain any information');
} }
// Build range // Build range
$counter = count($pRange); $counter = count($range);
for ($i = 0; $i < $counter; ++$i) { for ($i = 0; $i < $counter; ++$i) {
$pRange[$i] = implode(':', $pRange[$i]); $range[$i] = implode(':', $range[$i]);
} }
return implode(',', $pRange); return implode(',', $range);
} }
/** /**
* Calculate range boundaries. * Calculate range boundaries.
* *
* @param string $pRange Cell range (e.g. A1:A1) * @param string $range Cell range (e.g. A1:A1)
* *
* @return array Range coordinates [Start Cell, End Cell] * @return array Range coordinates [Start Cell, End Cell]
* where Start Cell and End Cell are arrays (Column Number, Row Number) * where Start Cell and End Cell are arrays (Column Number, Row Number)
*/ */
public static function rangeBoundaries($pRange) public static function rangeBoundaries($range)
{ {
// Ensure $pRange is a valid range // Ensure $pRange is a valid range
if (empty($pRange)) { if (empty($range)) {
$pRange = self::DEFAULT_RANGE; $range = self::DEFAULT_RANGE;
} }
// Uppercase coordinate // Uppercase coordinate
$pRange = strtoupper($pRange); $range = strtoupper($range);
// Extract range // Extract range
if (strpos($pRange, ':') === false) { if (strpos($range, ':') === false) {
$rangeA = $rangeB = $pRange; $rangeA = $rangeB = $range;
} else { } else {
[$rangeA, $rangeB] = explode(':', $pRange); [$rangeA, $rangeB] = explode(':', $range);
} }
// Calculate range outer borders // Calculate range outer borders
@ -196,14 +196,14 @@ abstract class Coordinate
/** /**
* Calculate range dimension. * Calculate range dimension.
* *
* @param string $pRange Cell range (e.g. A1:A1) * @param string $range Cell range (e.g. A1:A1)
* *
* @return array Range dimension (width, height) * @return array Range dimension (width, height)
*/ */
public static function rangeDimension($pRange) public static function rangeDimension($range)
{ {
// Calculate range outer borders // Calculate range outer borders
[$rangeStart, $rangeEnd] = self::rangeBoundaries($pRange); [$rangeStart, $rangeEnd] = self::rangeBoundaries($range);
return [($rangeEnd[0] - $rangeStart[0] + 1), ($rangeEnd[1] - $rangeStart[1] + 1)]; return [($rangeEnd[0] - $rangeStart[0] + 1), ($rangeEnd[1] - $rangeStart[1] + 1)];
} }
@ -211,26 +211,26 @@ abstract class Coordinate
/** /**
* Calculate range boundaries. * Calculate range boundaries.
* *
* @param string $pRange Cell range (e.g. A1:A1) * @param string $range Cell range (e.g. A1:A1)
* *
* @return array Range coordinates [Start Cell, End Cell] * @return array Range coordinates [Start Cell, End Cell]
* where Start Cell and End Cell are arrays [Column ID, Row Number] * where Start Cell and End Cell are arrays [Column ID, Row Number]
*/ */
public static function getRangeBoundaries($pRange) public static function getRangeBoundaries($range)
{ {
// Ensure $pRange is a valid range // Ensure $pRange is a valid range
if (empty($pRange)) { if (empty($range)) {
$pRange = self::DEFAULT_RANGE; $range = self::DEFAULT_RANGE;
} }
// Uppercase coordinate // Uppercase coordinate
$pRange = strtoupper($pRange); $range = strtoupper($range);
// Extract range // Extract range
if (strpos($pRange, ':') === false) { if (strpos($range, ':') === false) {
$rangeA = $rangeB = $pRange; $rangeA = $rangeB = $range;
} else { } else {
[$rangeA, $rangeB] = explode(':', $pRange); [$rangeA, $rangeB] = explode(':', $range);
} }
return [self::coordinateFromString($rangeA), self::coordinateFromString($rangeB)]; return [self::coordinateFromString($rangeA), self::coordinateFromString($rangeB)];
@ -239,19 +239,19 @@ abstract class Coordinate
/** /**
* Column index from string. * Column index from string.
* *
* @param string $pString eg 'A' * @param string $columnAddress eg 'A'
* *
* @return int Column index (A = 1) * @return int Column index (A = 1)
*/ */
public static function columnIndexFromString($pString) public static function columnIndexFromString($columnAddress)
{ {
// Using a lookup cache adds a slight memory overhead, but boosts speed // Using a lookup cache adds a slight memory overhead, but boosts speed
// caching using a static within the method is faster than a class static, // caching using a static within the method is faster than a class static,
// though it's additional memory overhead // though it's additional memory overhead
static $indexCache = []; static $indexCache = [];
if (isset($indexCache[$pString])) { if (isset($indexCache[$columnAddress])) {
return $indexCache[$pString]; return $indexCache[$columnAddress];
} }
// It's surprising how costly the strtoupper() and ord() calls actually are, so we use a lookup array rather than use ord() // It's surprising how costly the strtoupper() and ord() calls actually are, so we use a lookup array rather than use ord()
// and make it case insensitive to get rid of the strtoupper() as well. Because it's a static, there's no significant // and make it case insensitive to get rid of the strtoupper() as well. Because it's a static, there's no significant
@ -265,23 +265,23 @@ abstract class Coordinate
// We also use the language construct isset() rather than the more costly strlen() function to match the length of $pString // We also use the language construct isset() rather than the more costly strlen() function to match the length of $pString
// for improved performance // for improved performance
if (isset($pString[0])) { if (isset($columnAddress[0])) {
if (!isset($pString[1])) { if (!isset($columnAddress[1])) {
$indexCache[$pString] = $columnLookup[$pString]; $indexCache[$columnAddress] = $columnLookup[$columnAddress];
return $indexCache[$pString]; return $indexCache[$columnAddress];
} elseif (!isset($pString[2])) { } elseif (!isset($columnAddress[2])) {
$indexCache[$pString] = $columnLookup[$pString[0]] * 26 + $columnLookup[$pString[1]]; $indexCache[$columnAddress] = $columnLookup[$columnAddress[0]] * 26 + $columnLookup[$columnAddress[1]];
return $indexCache[$pString]; return $indexCache[$columnAddress];
} elseif (!isset($pString[3])) { } elseif (!isset($columnAddress[3])) {
$indexCache[$pString] = $columnLookup[$pString[0]] * 676 + $columnLookup[$pString[1]] * 26 + $columnLookup[$pString[2]]; $indexCache[$columnAddress] = $columnLookup[$columnAddress[0]] * 676 + $columnLookup[$columnAddress[1]] * 26 + $columnLookup[$columnAddress[2]];
return $indexCache[$pString]; return $indexCache[$columnAddress];
} }
} }
throw new Exception('Column string index can not be ' . ((isset($pString[0])) ? 'longer than 3 characters' : 'empty')); throw new Exception('Column string index can not be ' . ((isset($columnAddress[0])) ? 'longer than 3 characters' : 'empty'));
} }
/** /**
@ -435,16 +435,16 @@ abstract class Coordinate
* *
* [ 'A1:A3' => 'x', 'A4' => 'y' ] * [ 'A1:A3' => 'x', 'A4' => 'y' ]
* *
* @param array $pCoordCollection associative array mapping coordinates to values * @param array $coordinateCollection associative array mapping coordinates to values
* *
* @return array associative array mapping coordinate ranges to valuea * @return array associative array mapping coordinate ranges to valuea
*/ */
public static function mergeRangesInCollection(array $pCoordCollection) public static function mergeRangesInCollection(array $coordinateCollection)
{ {
$hashedValues = []; $hashedValues = [];
$mergedCoordCollection = []; $mergedCoordCollection = [];
foreach ($pCoordCollection as $coord => $value) { foreach ($coordinateCollection as $coord => $value) {
if (self::coordinateIsRange($coord)) { if (self::coordinateIsRange($coord)) {
$mergedCoordCollection[$coord] = $value; $mergedCoordCollection[$coord] = $value;

View File

@ -45,41 +45,41 @@ class DataType
/** /**
* Check a string that it satisfies Excel requirements. * Check a string that it satisfies Excel requirements.
* *
* @param null|RichText|string $pValue Value to sanitize to an Excel string * @param null|RichText|string $textValue Value to sanitize to an Excel string
* *
* @return null|RichText|string Sanitized value * @return null|RichText|string Sanitized value
*/ */
public static function checkString($pValue) public static function checkString($textValue)
{ {
if ($pValue instanceof RichText) { if ($textValue instanceof RichText) {
// TODO: Sanitize Rich-Text string (max. character count is 32,767) // TODO: Sanitize Rich-Text string (max. character count is 32,767)
return $pValue; return $textValue;
} }
// string must never be longer than 32,767 characters, truncate if necessary // string must never be longer than 32,767 characters, truncate if necessary
$pValue = StringHelper::substring($pValue, 0, 32767); $textValue = StringHelper::substring($textValue, 0, 32767);
// we require that newline is represented as "\n" in core, not as "\r\n" or "\r" // we require that newline is represented as "\n" in core, not as "\r\n" or "\r"
$pValue = str_replace(["\r\n", "\r"], "\n", $pValue); $textValue = str_replace(["\r\n", "\r"], "\n", $textValue);
return $pValue; return $textValue;
} }
/** /**
* Check a value that it is a valid error code. * Check a value that it is a valid error code.
* *
* @param mixed $pValue Value to sanitize to an Excel error code * @param mixed $value Value to sanitize to an Excel error code
* *
* @return string Sanitized value * @return string Sanitized value
*/ */
public static function checkErrorCode($pValue) public static function checkErrorCode($value)
{ {
$pValue = (string) $pValue; $value = (string) $value;
if (!isset(self::$errorCodes[$pValue])) { if (!isset(self::$errorCodes[$value])) {
$pValue = '#NULL!'; $value = '#NULL!';
} }
return $pValue; return $value;
} }
} }

View File

@ -140,13 +140,13 @@ class DataValidation
/** /**
* Set Formula 1. * Set Formula 1.
* *
* @param string $value * @param string $formula
* *
* @return $this * @return $this
*/ */
public function setFormula1($value) public function setFormula1($formula)
{ {
$this->formula1 = $value; $this->formula1 = $formula;
return $this; return $this;
} }
@ -164,13 +164,13 @@ class DataValidation
/** /**
* Set Formula 2. * Set Formula 2.
* *
* @param string $value * @param string $formula
* *
* @return $this * @return $this
*/ */
public function setFormula2($value) public function setFormula2($formula)
{ {
$this->formula2 = $value; $this->formula2 = $formula;
return $this; return $this;
} }
@ -188,13 +188,13 @@ class DataValidation
/** /**
* Set Type. * Set Type.
* *
* @param string $value * @param string $type
* *
* @return $this * @return $this
*/ */
public function setType($value) public function setType($type)
{ {
$this->type = $value; $this->type = $type;
return $this; return $this;
} }
@ -212,13 +212,13 @@ class DataValidation
/** /**
* Set Error style. * Set Error style.
* *
* @param string $value see self::STYLE_* * @param string $errorStye see self::STYLE_*
* *
* @return $this * @return $this
*/ */
public function setErrorStyle($value) public function setErrorStyle($errorStye)
{ {
$this->errorStyle = $value; $this->errorStyle = $errorStye;
return $this; return $this;
} }
@ -236,13 +236,13 @@ class DataValidation
/** /**
* Set Operator. * Set Operator.
* *
* @param string $value * @param string $operator
* *
* @return $this * @return $this
*/ */
public function setOperator($value) public function setOperator($operator)
{ {
$this->operator = $value; $this->operator = $operator;
return $this; return $this;
} }
@ -260,13 +260,13 @@ class DataValidation
/** /**
* Set Allow Blank. * Set Allow Blank.
* *
* @param bool $value * @param bool $allowBlank
* *
* @return $this * @return $this
*/ */
public function setAllowBlank($value) public function setAllowBlank($allowBlank)
{ {
$this->allowBlank = $value; $this->allowBlank = $allowBlank;
return $this; return $this;
} }
@ -284,13 +284,13 @@ class DataValidation
/** /**
* Set Show DropDown. * Set Show DropDown.
* *
* @param bool $value * @param bool $showDropDown
* *
* @return $this * @return $this
*/ */
public function setShowDropDown($value) public function setShowDropDown($showDropDown)
{ {
$this->showDropDown = $value; $this->showDropDown = $showDropDown;
return $this; return $this;
} }
@ -308,13 +308,13 @@ class DataValidation
/** /**
* Set Show InputMessage. * Set Show InputMessage.
* *
* @param bool $value * @param bool $showInputMessage
* *
* @return $this * @return $this
*/ */
public function setShowInputMessage($value) public function setShowInputMessage($showInputMessage)
{ {
$this->showInputMessage = $value; $this->showInputMessage = $showInputMessage;
return $this; return $this;
} }
@ -332,13 +332,13 @@ class DataValidation
/** /**
* Set Show ErrorMessage. * Set Show ErrorMessage.
* *
* @param bool $value * @param bool $showErrorMessage
* *
* @return $this * @return $this
*/ */
public function setShowErrorMessage($value) public function setShowErrorMessage($showErrorMessage)
{ {
$this->showErrorMessage = $value; $this->showErrorMessage = $showErrorMessage;
return $this; return $this;
} }
@ -356,13 +356,13 @@ class DataValidation
/** /**
* Set Error title. * Set Error title.
* *
* @param string $value * @param string $errorTitle
* *
* @return $this * @return $this
*/ */
public function setErrorTitle($value) public function setErrorTitle($errorTitle)
{ {
$this->errorTitle = $value; $this->errorTitle = $errorTitle;
return $this; return $this;
} }
@ -380,13 +380,13 @@ class DataValidation
/** /**
* Set Error. * Set Error.
* *
* @param string $value * @param string $error
* *
* @return $this * @return $this
*/ */
public function setError($value) public function setError($error)
{ {
$this->error = $value; $this->error = $error;
return $this; return $this;
} }
@ -404,13 +404,13 @@ class DataValidation
/** /**
* Set Prompt title. * Set Prompt title.
* *
* @param string $value * @param string $promptTitle
* *
* @return $this * @return $this
*/ */
public function setPromptTitle($value) public function setPromptTitle($promptTitle)
{ {
$this->promptTitle = $value; $this->promptTitle = $promptTitle;
return $this; return $this;
} }
@ -428,13 +428,13 @@ class DataValidation
/** /**
* Set Prompt. * Set Prompt.
* *
* @param string $value * @param string $prompt
* *
* @return $this * @return $this
*/ */
public function setPrompt($value) public function setPrompt($prompt)
{ {
$this->prompt = $value; $this->prompt = $prompt;
return $this; return $this;
} }

View File

@ -21,14 +21,14 @@ class Hyperlink
/** /**
* Create a new Hyperlink. * Create a new Hyperlink.
* *
* @param string $pUrl Url to link the cell to * @param string $url Url to link the cell to
* @param string $pTooltip Tooltip to display on the hyperlink * @param string $tooltip Tooltip to display on the hyperlink
*/ */
public function __construct($pUrl = '', $pTooltip = '') public function __construct($url = '', $tooltip = '')
{ {
// Initialise member variables // Initialise member variables
$this->url = $pUrl; $this->url = $url;
$this->tooltip = $pTooltip; $this->tooltip = $tooltip;
} }
/** /**
@ -44,13 +44,13 @@ class Hyperlink
/** /**
* Set URL. * Set URL.
* *
* @param string $value * @param string $url
* *
* @return $this * @return $this
*/ */
public function setUrl($value) public function setUrl($url)
{ {
$this->url = $value; $this->url = $url;
return $this; return $this;
} }
@ -68,13 +68,13 @@ class Hyperlink
/** /**
* Set tooltip. * Set tooltip.
* *
* @param string $value * @param string $tooltip
* *
* @return $this * @return $this
*/ */
public function setTooltip($value) public function setTooltip($tooltip)
{ {
$this->tooltip = $value; $this->tooltip = $tooltip;
return $this; return $this;
} }