Sane argument names for Styles

This commit is contained in:
MarkBaker 2020-11-05 20:04:35 +01:00
parent 317965078d
commit 86728cb214
10 changed files with 281 additions and 281 deletions

View File

@ -140,36 +140,36 @@ class Alignment extends Supervisor
* );
* </code>
*
* @param array $pStyles Array containing style information
* @param array $styleArray Array containing style information
*
* @return $this
*/
public function applyFromArray(array $pStyles)
public function applyFromArray(array $styleArray)
{
if ($this->isSupervisor) {
$this->getActiveSheet()->getStyle($this->getSelectedCells())
->applyFromArray($this->getStyleArray($pStyles));
->applyFromArray($this->getStyleArray($styleArray));
} else {
if (isset($pStyles['horizontal'])) {
$this->setHorizontal($pStyles['horizontal']);
if (isset($styleArray['horizontal'])) {
$this->setHorizontal($styleArray['horizontal']);
}
if (isset($pStyles['vertical'])) {
$this->setVertical($pStyles['vertical']);
if (isset($styleArray['vertical'])) {
$this->setVertical($styleArray['vertical']);
}
if (isset($pStyles['textRotation'])) {
$this->setTextRotation($pStyles['textRotation']);
if (isset($styleArray['textRotation'])) {
$this->setTextRotation($styleArray['textRotation']);
}
if (isset($pStyles['wrapText'])) {
$this->setWrapText($pStyles['wrapText']);
if (isset($styleArray['wrapText'])) {
$this->setWrapText($styleArray['wrapText']);
}
if (isset($pStyles['shrinkToFit'])) {
$this->setShrinkToFit($pStyles['shrinkToFit']);
if (isset($styleArray['shrinkToFit'])) {
$this->setShrinkToFit($styleArray['shrinkToFit']);
}
if (isset($pStyles['indent'])) {
$this->setIndent($pStyles['indent']);
if (isset($styleArray['indent'])) {
$this->setIndent($styleArray['indent']);
}
if (isset($pStyles['readOrder'])) {
$this->setReadOrder($pStyles['readOrder']);
if (isset($styleArray['readOrder'])) {
$this->setReadOrder($styleArray['readOrder']);
}
}
@ -267,24 +267,24 @@ class Alignment extends Supervisor
/**
* Set TextRotation.
*
* @param int $rotation
* @param int $angleInDegrees
*
* @return $this
*/
public function setTextRotation($rotation)
public function setTextRotation($angleInDegrees)
{
// Excel2007 value 255 => PhpSpreadsheet value -165
if ($rotation == self::TEXTROTATION_STACK_EXCEL) {
$rotation = self::TEXTROTATION_STACK_PHPSPREADSHEET;
if ($angleInDegrees == self::TEXTROTATION_STACK_EXCEL) {
$angleInDegrees = self::TEXTROTATION_STACK_PHPSPREADSHEET;
}
// Set rotation
if (($rotation >= -90 && $rotation <= 90) || $rotation == self::TEXTROTATION_STACK_PHPSPREADSHEET) {
if (($angleInDegrees >= -90 && $angleInDegrees <= 90) || $angleInDegrees == self::TEXTROTATION_STACK_PHPSPREADSHEET) {
if ($this->isSupervisor) {
$styleArray = $this->getStyleArray(['textRotation' => $rotation]);
$styleArray = $this->getStyleArray(['textRotation' => $angleInDegrees]);
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
} else {
$this->textRotation = $rotation;
$this->textRotation = $angleInDegrees;
}
} else {
throw new PhpSpreadsheetException('Text rotation should be a value between -90 and 90.');

View File

@ -115,20 +115,20 @@ class Border extends Supervisor
* );
* </code>
*
* @param array $pStyles Array containing style information
* @param array $styleArray Array containing style information
*
* @return $this
*/
public function applyFromArray(array $pStyles)
public function applyFromArray(array $styleArray)
{
if ($this->isSupervisor) {
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($pStyles));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($styleArray));
} else {
if (isset($pStyles['borderStyle'])) {
$this->setBorderStyle($pStyles['borderStyle']);
if (isset($styleArray['borderStyle'])) {
$this->setBorderStyle($styleArray['borderStyle']);
}
if (isset($pStyles['color'])) {
$this->getColor()->applyFromArray($pStyles['color']);
if (isset($styleArray['color'])) {
$this->getColor()->applyFromArray($styleArray['color']);
}
}

View File

@ -193,38 +193,38 @@ class Borders extends Supervisor
* );
* </code>
*
* @param array $pStyles Array containing style information
* @param array $styleArray Array containing style information
*
* @return $this
*/
public function applyFromArray(array $pStyles)
public function applyFromArray(array $styleArray)
{
if ($this->isSupervisor) {
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($pStyles));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($styleArray));
} else {
if (isset($pStyles['left'])) {
$this->getLeft()->applyFromArray($pStyles['left']);
if (isset($styleArray['left'])) {
$this->getLeft()->applyFromArray($styleArray['left']);
}
if (isset($pStyles['right'])) {
$this->getRight()->applyFromArray($pStyles['right']);
if (isset($styleArray['right'])) {
$this->getRight()->applyFromArray($styleArray['right']);
}
if (isset($pStyles['top'])) {
$this->getTop()->applyFromArray($pStyles['top']);
if (isset($styleArray['top'])) {
$this->getTop()->applyFromArray($styleArray['top']);
}
if (isset($pStyles['bottom'])) {
$this->getBottom()->applyFromArray($pStyles['bottom']);
if (isset($styleArray['bottom'])) {
$this->getBottom()->applyFromArray($styleArray['bottom']);
}
if (isset($pStyles['diagonal'])) {
$this->getDiagonal()->applyFromArray($pStyles['diagonal']);
if (isset($styleArray['diagonal'])) {
$this->getDiagonal()->applyFromArray($styleArray['diagonal']);
}
if (isset($pStyles['diagonalDirection'])) {
$this->setDiagonalDirection($pStyles['diagonalDirection']);
if (isset($styleArray['diagonalDirection'])) {
$this->setDiagonalDirection($styleArray['diagonalDirection']);
}
if (isset($pStyles['allBorders'])) {
$this->getLeft()->applyFromArray($pStyles['allBorders']);
$this->getRight()->applyFromArray($pStyles['allBorders']);
$this->getTop()->applyFromArray($pStyles['allBorders']);
$this->getBottom()->applyFromArray($pStyles['allBorders']);
if (isset($styleArray['allBorders'])) {
$this->getLeft()->applyFromArray($styleArray['allBorders']);
$this->getRight()->applyFromArray($styleArray['allBorders']);
$this->getTop()->applyFromArray($styleArray['allBorders']);
$this->getBottom()->applyFromArray($styleArray['allBorders']);
}
}
@ -368,20 +368,20 @@ class Borders extends Supervisor
/**
* Set DiagonalDirection.
*
* @param int $pValue see self::DIAGONAL_*
* @param int $direction see self::DIAGONAL_*
*
* @return $this
*/
public function setDiagonalDirection($pValue)
public function setDiagonalDirection($direction)
{
if ($pValue == '') {
$pValue = self::DIAGONAL_NONE;
if ($direction == '') {
$direction = self::DIAGONAL_NONE;
}
if ($this->isSupervisor) {
$styleArray = $this->getStyleArray(['diagonalDirection' => $pValue]);
$styleArray = $this->getStyleArray(['diagonalDirection' => $direction]);
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
} else {
$this->diagonalDirection = $pValue;
$this->diagonalDirection = $direction;
}
return $this;

View File

@ -104,20 +104,20 @@ class Color extends Supervisor
* $spreadsheet->getActiveSheet()->getStyle('B2')->getFont()->getColor()->applyFromArray(['rgb' => '808080']);
* </code>
*
* @param array $styles Array containing style information
* @param array $styleArray Array containing style information
*
* @return $this
*/
public function applyFromArray(array $styles)
public function applyFromArray(array $styleArray)
{
if ($this->isSupervisor) {
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($styles));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($styleArray));
} else {
if (isset($styles['rgb'])) {
$this->setRGB($styles['rgb']);
if (isset($styleArray['rgb'])) {
$this->setRGB($styleArray['rgb']);
}
if (isset($styles['argb'])) {
$this->setARGB($styles['argb']);
if (isset($styleArray['argb'])) {
$this->setARGB($styleArray['argb']);
}
}
@ -211,16 +211,16 @@ class Color extends Supervisor
/**
* Get a specified colour component of an RGB value.
*
* @param string $RGB The colour as an RGB value (e.g. FF00CCCC or CCDDEE
* @param string $rgbValue The colour as an RGB value (e.g. FF00CCCC or CCDDEE
* @param int $offset Position within the RGB value to extract
* @param bool $hex Flag indicating whether the component should be returned as a hex or a
* decimal value
*
* @return string The extracted colour component
*/
private static function getColourComponent($RGB, $offset, $hex = true)
private static function getColourComponent($rgbValue, $offset, $hex = true)
{
$colour = substr($RGB, $offset, 2);
$colour = substr($rgbValue, $offset, 2);
return ($hex) ? $colour : hexdec($colour);
}
@ -228,43 +228,43 @@ class Color extends Supervisor
/**
* Get the red colour component of an RGB value.
*
* @param string $RGB The colour as an RGB value (e.g. FF00CCCC or CCDDEE
* @param string $rgbValue The colour as an RGB value (e.g. FF00CCCC or CCDDEE
* @param bool $hex Flag indicating whether the component should be returned as a hex or a
* decimal value
*
* @return string The red colour component
*/
public static function getRed($RGB, $hex = true)
public static function getRed($rgbValue, $hex = true)
{
return self::getColourComponent($RGB, strlen($RGB) - 6, $hex);
return self::getColourComponent($rgbValue, strlen($rgbValue) - 6, $hex);
}
/**
* Get the green colour component of an RGB value.
*
* @param string $RGB The colour as an RGB value (e.g. FF00CCCC or CCDDEE
* @param string $rgbValue The colour as an RGB value (e.g. FF00CCCC or CCDDEE
* @param bool $hex Flag indicating whether the component should be returned as a hex or a
* decimal value
*
* @return string The green colour component
*/
public static function getGreen($RGB, $hex = true)
public static function getGreen($rgbValue, $hex = true)
{
return self::getColourComponent($RGB, strlen($RGB) - 4, $hex);
return self::getColourComponent($rgbValue, strlen($rgbValue) - 4, $hex);
}
/**
* Get the blue colour component of an RGB value.
*
* @param string $RGB The colour as an RGB value (e.g. FF00CCCC or CCDDEE
* @param string $rgbValue The colour as an RGB value (e.g. FF00CCCC or CCDDEE
* @param bool $hex Flag indicating whether the component should be returned as a hex or a
* decimal value
*
* @return string The blue colour component
*/
public static function getBlue($RGB, $hex = true)
public static function getBlue($rgbValue, $hex = true)
{
return self::getColourComponent($RGB, strlen($RGB) - 2, $hex);
return self::getColourComponent($rgbValue, strlen($rgbValue) - 2, $hex);
}
/**

View File

@ -93,13 +93,13 @@ class Conditional implements IComparable
/**
* Set Condition type.
*
* @param string $pValue Condition type, see self::CONDITION_*
* @param string $type Condition type, see self::CONDITION_*
*
* @return $this
*/
public function setConditionType($pValue)
public function setConditionType($type)
{
$this->conditionType = $pValue;
$this->conditionType = $type;
return $this;
}
@ -117,13 +117,13 @@ class Conditional implements IComparable
/**
* Set Operator type.
*
* @param string $pValue Conditional operator type, see self::OPERATOR_*
* @param string $type Conditional operator type, see self::OPERATOR_*
*
* @return $this
*/
public function setOperatorType($pValue)
public function setOperatorType($type)
{
$this->operatorType = $pValue;
$this->operatorType = $type;
return $this;
}
@ -141,13 +141,13 @@ class Conditional implements IComparable
/**
* Set text.
*
* @param string $value
* @param string $text
*
* @return $this
*/
public function setText($value)
public function setText($text)
{
$this->text = $value;
$this->text = $text;
return $this;
}
@ -165,13 +165,13 @@ class Conditional implements IComparable
/**
* Set StopIfTrue.
*
* @param bool $value
* @param bool $stopIfTrue
*
* @return $this
*/
public function setStopIfTrue($value)
public function setStopIfTrue($stopIfTrue)
{
$this->stopIfTrue = $value;
$this->stopIfTrue = $stopIfTrue;
return $this;
}
@ -189,16 +189,16 @@ class Conditional implements IComparable
/**
* Set Conditions.
*
* @param string[] $pValue Condition
* @param string[] $conditions Condition
*
* @return $this
*/
public function setConditions($pValue)
public function setConditions($conditions)
{
if (!is_array($pValue)) {
$pValue = [$pValue];
if (!is_array($conditions)) {
$conditions = [$conditions];
}
$this->condition = $pValue;
$this->condition = $conditions;
return $this;
}
@ -206,13 +206,13 @@ class Conditional implements IComparable
/**
* Add Condition.
*
* @param string $pValue Condition
* @param string $comdition Condition
*
* @return $this
*/
public function addCondition($pValue)
public function addCondition($comdition)
{
$this->condition[] = $pValue;
$this->condition[] = $comdition;
return $this;
}
@ -230,13 +230,13 @@ class Conditional implements IComparable
/**
* Set Style.
*
* @param Style $pValue
* @param Style $style
*
* @return $this
*/
public function setStyle(?Style $pValue = null)
public function setStyle(?Style $style = null)
{
$this->style = $pValue;
$this->style = $style;
return $this;
}

View File

@ -135,30 +135,30 @@ class Fill extends Supervisor
* );
* </code>
*
* @param array $pStyles Array containing style information
* @param array $styleArray Array containing style information
*
* @return $this
*/
public function applyFromArray(array $pStyles)
public function applyFromArray(array $styleArray)
{
if ($this->isSupervisor) {
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($pStyles));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($styleArray));
} else {
if (isset($pStyles['fillType'])) {
$this->setFillType($pStyles['fillType']);
if (isset($styleArray['fillType'])) {
$this->setFillType($styleArray['fillType']);
}
if (isset($pStyles['rotation'])) {
$this->setRotation($pStyles['rotation']);
if (isset($styleArray['rotation'])) {
$this->setRotation($styleArray['rotation']);
}
if (isset($pStyles['startColor'])) {
$this->getStartColor()->applyFromArray($pStyles['startColor']);
if (isset($styleArray['startColor'])) {
$this->getStartColor()->applyFromArray($styleArray['startColor']);
}
if (isset($pStyles['endColor'])) {
$this->getEndColor()->applyFromArray($pStyles['endColor']);
if (isset($styleArray['endColor'])) {
$this->getEndColor()->applyFromArray($styleArray['endColor']);
}
if (isset($pStyles['color'])) {
$this->getStartColor()->applyFromArray($pStyles['color']);
$this->getEndColor()->applyFromArray($pStyles['color']);
if (isset($styleArray['color'])) {
$this->getStartColor()->applyFromArray($styleArray['color']);
$this->getEndColor()->applyFromArray($styleArray['color']);
}
}
@ -182,17 +182,17 @@ class Fill extends Supervisor
/**
* Set Fill Type.
*
* @param string $pValue Fill type, see self::FILL_*
* @param string $fillType Fill type, see self::FILL_*
*
* @return $this
*/
public function setFillType($pValue)
public function setFillType($fillType)
{
if ($this->isSupervisor) {
$styleArray = $this->getStyleArray(['fillType' => $pValue]);
$styleArray = $this->getStyleArray(['fillType' => $fillType]);
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
} else {
$this->fillType = $pValue;
$this->fillType = $fillType;
}
return $this;
@ -215,17 +215,17 @@ class Fill extends Supervisor
/**
* Set Rotation.
*
* @param float $pValue
* @param float $angleInDegrees
*
* @return $this
*/
public function setRotation($pValue)
public function setRotation($angleInDegrees)
{
if ($this->isSupervisor) {
$styleArray = $this->getStyleArray(['rotation' => $pValue]);
$styleArray = $this->getStyleArray(['rotation' => $angleInDegrees]);
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
} else {
$this->rotation = $pValue;
$this->rotation = $angleInDegrees;
}
return $this;
@ -246,10 +246,10 @@ class Fill extends Supervisor
*
* @return $this
*/
public function setStartColor(Color $pValue)
public function setStartColor(Color $color)
{
// make sure parameter is a real color and not a supervisor
$color = $pValue->getIsSupervisor() ? $pValue->getSharedComponent() : $pValue;
$color = $color->getIsSupervisor() ? $color->getSharedComponent() : $color;
if ($this->isSupervisor) {
$styleArray = $this->getStartColor()->getStyleArray(['argb' => $color->getARGB()]);
@ -276,10 +276,10 @@ class Fill extends Supervisor
*
* @return $this
*/
public function setEndColor(Color $pValue)
public function setEndColor(Color $color)
{
// make sure parameter is a real color and not a supervisor
$color = $pValue->getIsSupervisor() ? $pValue->getSharedComponent() : $pValue;
$color = $color->getIsSupervisor() ? $color->getSharedComponent() : $color;
if ($this->isSupervisor) {
$styleArray = $this->getEndColor()->getStyleArray(['argb' => $color->getARGB()]);

View File

@ -155,41 +155,41 @@ class Font extends Supervisor
* );
* </code>
*
* @param array $pStyles Array containing style information
* @param array $styleArray Array containing style information
*
* @return $this
*/
public function applyFromArray(array $pStyles)
public function applyFromArray(array $styleArray)
{
if ($this->isSupervisor) {
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($pStyles));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($styleArray));
} else {
if (isset($pStyles['name'])) {
$this->setName($pStyles['name']);
if (isset($styleArray['name'])) {
$this->setName($styleArray['name']);
}
if (isset($pStyles['bold'])) {
$this->setBold($pStyles['bold']);
if (isset($styleArray['bold'])) {
$this->setBold($styleArray['bold']);
}
if (isset($pStyles['italic'])) {
$this->setItalic($pStyles['italic']);
if (isset($styleArray['italic'])) {
$this->setItalic($styleArray['italic']);
}
if (isset($pStyles['superscript'])) {
$this->setSuperscript($pStyles['superscript']);
if (isset($styleArray['superscript'])) {
$this->setSuperscript($styleArray['superscript']);
}
if (isset($pStyles['subscript'])) {
$this->setSubscript($pStyles['subscript']);
if (isset($styleArray['subscript'])) {
$this->setSubscript($styleArray['subscript']);
}
if (isset($pStyles['underline'])) {
$this->setUnderline($pStyles['underline']);
if (isset($styleArray['underline'])) {
$this->setUnderline($styleArray['underline']);
}
if (isset($pStyles['strikethrough'])) {
$this->setStrikethrough($pStyles['strikethrough']);
if (isset($styleArray['strikethrough'])) {
$this->setStrikethrough($styleArray['strikethrough']);
}
if (isset($pStyles['color'])) {
$this->getColor()->applyFromArray($pStyles['color']);
if (isset($styleArray['color'])) {
$this->getColor()->applyFromArray($styleArray['color']);
}
if (isset($pStyles['size'])) {
$this->setSize($pStyles['size']);
if (isset($styleArray['size'])) {
$this->setSize($styleArray['size']);
}
}
@ -213,20 +213,20 @@ class Font extends Supervisor
/**
* Set Name.
*
* @param string $pValue
* @param string $fontName
*
* @return $this
*/
public function setName($pValue)
public function setName($fontName)
{
if ($pValue == '') {
$pValue = 'Calibri';
if ($fontName == '') {
$fontName = 'Calibri';
}
if ($this->isSupervisor) {
$styleArray = $this->getStyleArray(['name' => $pValue]);
$styleArray = $this->getStyleArray(['name' => $fontName]);
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
} else {
$this->name = $pValue;
$this->name = $fontName;
}
return $this;
@ -249,20 +249,20 @@ class Font extends Supervisor
/**
* Set Size.
*
* @param float $pValue
* @param float $fontSize
*
* @return $this
*/
public function setSize($pValue)
public function setSize($fontSize)
{
if ($pValue == '') {
$pValue = 10;
if ($fontSize == '') {
$fontSize = 10;
}
if ($this->isSupervisor) {
$styleArray = $this->getStyleArray(['size' => $pValue]);
$styleArray = $this->getStyleArray(['size' => $fontSize]);
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
} else {
$this->size = $pValue;
$this->size = $fontSize;
}
return $this;
@ -285,20 +285,20 @@ class Font extends Supervisor
/**
* Set Bold.
*
* @param bool $pValue
* @param bool $bold
*
* @return $this
*/
public function setBold($pValue)
public function setBold($bold)
{
if ($pValue == '') {
$pValue = false;
if ($bold == '') {
$bold = false;
}
if ($this->isSupervisor) {
$styleArray = $this->getStyleArray(['bold' => $pValue]);
$styleArray = $this->getStyleArray(['bold' => $bold]);
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
} else {
$this->bold = $pValue;
$this->bold = $bold;
}
return $this;
@ -321,20 +321,20 @@ class Font extends Supervisor
/**
* Set Italic.
*
* @param bool $pValue
* @param bool $italic
*
* @return $this
*/
public function setItalic($pValue)
public function setItalic($italic)
{
if ($pValue == '') {
$pValue = false;
if ($italic == '') {
$italic = false;
}
if ($this->isSupervisor) {
$styleArray = $this->getStyleArray(['italic' => $pValue]);
$styleArray = $this->getStyleArray(['italic' => $italic]);
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
} else {
$this->italic = $pValue;
$this->italic = $italic;
}
return $this;
@ -359,13 +359,13 @@ class Font extends Supervisor
*
* @return $this
*/
public function setSuperscript(bool $pValue)
public function setSuperscript(bool $superscript)
{
if ($this->isSupervisor) {
$styleArray = $this->getStyleArray(['superscript' => $pValue]);
$styleArray = $this->getStyleArray(['superscript' => $superscript]);
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
} else {
$this->superscript = $pValue;
$this->superscript = $superscript;
if ($this->superscript) {
$this->subscript = false;
}
@ -393,13 +393,13 @@ class Font extends Supervisor
*
* @return $this
*/
public function setSubscript(bool $pValue)
public function setSubscript(bool $subscript)
{
if ($this->isSupervisor) {
$styleArray = $this->getStyleArray(['subscript' => $pValue]);
$styleArray = $this->getStyleArray(['subscript' => $subscript]);
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
} else {
$this->subscript = $pValue;
$this->subscript = $subscript;
if ($this->subscript) {
$this->superscript = false;
}
@ -425,24 +425,24 @@ class Font extends Supervisor
/**
* Set Underline.
*
* @param bool|string $pValue \PhpOffice\PhpSpreadsheet\Style\Font underline type
* @param bool|string $underlineStyle \PhpOffice\PhpSpreadsheet\Style\Font underline type
* If a boolean is passed, then TRUE equates to UNDERLINE_SINGLE,
* false equates to UNDERLINE_NONE
*
* @return $this
*/
public function setUnderline($pValue)
public function setUnderline($underlineStyle)
{
if (is_bool($pValue)) {
$pValue = ($pValue) ? self::UNDERLINE_SINGLE : self::UNDERLINE_NONE;
} elseif ($pValue == '') {
$pValue = self::UNDERLINE_NONE;
if (is_bool($underlineStyle)) {
$underlineStyle = ($underlineStyle) ? self::UNDERLINE_SINGLE : self::UNDERLINE_NONE;
} elseif ($underlineStyle == '') {
$underlineStyle = self::UNDERLINE_NONE;
}
if ($this->isSupervisor) {
$styleArray = $this->getStyleArray(['underline' => $pValue]);
$styleArray = $this->getStyleArray(['underline' => $underlineStyle]);
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
} else {
$this->underline = $pValue;
$this->underline = $underlineStyle;
}
return $this;
@ -465,21 +465,21 @@ class Font extends Supervisor
/**
* Set Strikethrough.
*
* @param bool $pValue
* @param bool $strikethru
*
* @return $this
*/
public function setStrikethrough($pValue)
public function setStrikethrough($strikethru)
{
if ($pValue == '') {
$pValue = false;
if ($strikethru == '') {
$strikethru = false;
}
if ($this->isSupervisor) {
$styleArray = $this->getStyleArray(['strikethrough' => $pValue]);
$styleArray = $this->getStyleArray(['strikethrough' => $strikethru]);
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
} else {
$this->strikethrough = $pValue;
$this->strikethrough = $strikethru;
}
return $this;
@ -500,10 +500,10 @@ class Font extends Supervisor
*
* @return $this
*/
public function setColor(Color $pValue)
public function setColor(Color $color)
{
// make sure parameter is a real color and not a supervisor
$color = $pValue->getIsSupervisor() ? $pValue->getSharedComponent() : $pValue;
$color = $color->getIsSupervisor() ? $color->getSharedComponent() : $color;
if ($this->isSupervisor) {
$styleArray = $this->getColor()->getStyleArray(['argb' => $color->getARGB()]);

View File

@ -134,17 +134,17 @@ class NumberFormat extends Supervisor
* );
* </code>
*
* @param array $pStyles Array containing style information
* @param array $styleArray Array containing style information
*
* @return $this
*/
public function applyFromArray(array $pStyles)
public function applyFromArray(array $styleArray)
{
if ($this->isSupervisor) {
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($pStyles));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($styleArray));
} else {
if (isset($pStyles['formatCode'])) {
$this->setFormatCode($pStyles['formatCode']);
if (isset($styleArray['formatCode'])) {
$this->setFormatCode($styleArray['formatCode']);
}
}
@ -171,21 +171,21 @@ class NumberFormat extends Supervisor
/**
* Set Format Code.
*
* @param string $pValue see self::FORMAT_*
* @param string $formatCode see self::FORMAT_*
*
* @return $this
*/
public function setFormatCode($pValue)
public function setFormatCode($formatCode)
{
if ($pValue == '') {
$pValue = self::FORMAT_GENERAL;
if ($formatCode == '') {
$formatCode = self::FORMAT_GENERAL;
}
if ($this->isSupervisor) {
$styleArray = $this->getStyleArray(['formatCode' => $pValue]);
$styleArray = $this->getStyleArray(['formatCode' => $formatCode]);
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
} else {
$this->formatCode = $pValue;
$this->builtInFormatCode = self::builtInFormatCodeIndex($pValue);
$this->formatCode = $formatCode;
$this->builtInFormatCode = self::builtInFormatCodeIndex($formatCode);
}
return $this;
@ -208,18 +208,18 @@ class NumberFormat extends Supervisor
/**
* Set Built-In Format Code.
*
* @param int $pValue
* @param int $formatCodeIndex
*
* @return $this
*/
public function setBuiltInFormatCode($pValue)
public function setBuiltInFormatCode($formatCodeIndex)
{
if ($this->isSupervisor) {
$styleArray = $this->getStyleArray(['formatCode' => self::builtInFormatCode($pValue)]);
$styleArray = $this->getStyleArray(['formatCode' => self::builtInFormatCode($formatCodeIndex)]);
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
} else {
$this->builtInFormatCode = $pValue;
$this->formatCode = self::builtInFormatCode($pValue);
$this->builtInFormatCode = $formatCodeIndex;
$this->formatCode = self::builtInFormatCode($formatCodeIndex);
}
return $this;
@ -331,21 +331,21 @@ class NumberFormat extends Supervisor
/**
* Get built-in format code.
*
* @param int $pIndex
* @param int $index
*
* @return string
*/
public static function builtInFormatCode($pIndex)
public static function builtInFormatCode($index)
{
// Clean parameter
$pIndex = (int) $pIndex;
$index = (int) $index;
// Ensure built-in format codes are available
self::fillBuiltInFormatCodes();
// Lookup format code
if (isset(self::$builtInFormats[$pIndex])) {
return self::$builtInFormats[$pIndex];
if (isset(self::$builtInFormats[$index])) {
return self::$builtInFormats[$index];
}
return '';
@ -354,18 +354,18 @@ class NumberFormat extends Supervisor
/**
* Get built-in format code index.
*
* @param string $formatCode
* @param string $formatCodeIndex
*
* @return bool|int
*/
public static function builtInFormatCodeIndex($formatCode)
public static function builtInFormatCodeIndex($formatCodeIndex)
{
// Ensure built-in format codes are available
self::fillBuiltInFormatCodes();
// Lookup format code
if (array_key_exists($formatCode, self::$flippedBuiltInFormats)) {
return self::$flippedBuiltInFormats[$formatCode];
if (array_key_exists($formatCodeIndex, self::$flippedBuiltInFormats)) {
return self::$flippedBuiltInFormats[$formatCodeIndex];
}
return false;

View File

@ -80,20 +80,20 @@ class Protection extends Supervisor
* );
* </code>
*
* @param array $pStyles Array containing style information
* @param array $styleArray Array containing style information
*
* @return $this
*/
public function applyFromArray(array $pStyles)
public function applyFromArray(array $styleArray)
{
if ($this->isSupervisor) {
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($pStyles));
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($this->getStyleArray($styleArray));
} else {
if (isset($pStyles['locked'])) {
$this->setLocked($pStyles['locked']);
if (isset($styleArray['locked'])) {
$this->setLocked($styleArray['locked']);
}
if (isset($pStyles['hidden'])) {
$this->setHidden($pStyles['hidden']);
if (isset($styleArray['hidden'])) {
$this->setHidden($styleArray['hidden']);
}
}
@ -117,17 +117,17 @@ class Protection extends Supervisor
/**
* Set locked.
*
* @param string $pValue see self::PROTECTION_*
* @param string $lockType see self::PROTECTION_*
*
* @return $this
*/
public function setLocked($pValue)
public function setLocked($lockType)
{
if ($this->isSupervisor) {
$styleArray = $this->getStyleArray(['locked' => $pValue]);
$styleArray = $this->getStyleArray(['locked' => $lockType]);
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
} else {
$this->locked = $pValue;
$this->locked = $lockType;
}
return $this;
@ -150,17 +150,17 @@ class Protection extends Supervisor
/**
* Set hidden.
*
* @param string $pValue see self::PROTECTION_*
* @param string $hiddenType see self::PROTECTION_*
*
* @return $this
*/
public function setHidden($pValue)
public function setHidden($hiddenType)
{
if ($this->isSupervisor) {
$styleArray = $this->getStyleArray(['hidden' => $pValue]);
$styleArray = $this->getStyleArray(['hidden' => $hiddenType]);
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
} else {
$this->hidden = $pValue;
$this->hidden = $hiddenType;
}
return $this;

View File

@ -184,12 +184,12 @@ class Style extends Supervisor
* );
* </code>
*
* @param array $pStyles Array containing style information
* @param bool $pAdvanced advanced mode for setting borders
* @param array $styleArray Array containing style information
* @param bool $advancedBorders advanced mode for setting borders
*
* @return $this
*/
public function applyFromArray(array $pStyles, $pAdvanced = true)
public function applyFromArray(array $styleArray, $advancedBorders = true)
{
if ($this->isSupervisor) {
$pRange = $this->getSelectedCells();
@ -221,36 +221,36 @@ class Style extends Supervisor
}
// ADVANCED MODE:
if ($pAdvanced && isset($pStyles['borders'])) {
if ($advancedBorders && isset($styleArray['borders'])) {
// 'allBorders' is a shorthand property for 'outline' and 'inside' and
// it applies to components that have not been set explicitly
if (isset($pStyles['borders']['allBorders'])) {
if (isset($styleArray['borders']['allBorders'])) {
foreach (['outline', 'inside'] as $component) {
if (!isset($pStyles['borders'][$component])) {
$pStyles['borders'][$component] = $pStyles['borders']['allBorders'];
if (!isset($styleArray['borders'][$component])) {
$styleArray['borders'][$component] = $styleArray['borders']['allBorders'];
}
}
unset($pStyles['borders']['allBorders']); // not needed any more
unset($styleArray['borders']['allBorders']); // not needed any more
}
// 'outline' is a shorthand property for 'top', 'right', 'bottom', 'left'
// it applies to components that have not been set explicitly
if (isset($pStyles['borders']['outline'])) {
if (isset($styleArray['borders']['outline'])) {
foreach (['top', 'right', 'bottom', 'left'] as $component) {
if (!isset($pStyles['borders'][$component])) {
$pStyles['borders'][$component] = $pStyles['borders']['outline'];
if (!isset($styleArray['borders'][$component])) {
$styleArray['borders'][$component] = $styleArray['borders']['outline'];
}
}
unset($pStyles['borders']['outline']); // not needed any more
unset($styleArray['borders']['outline']); // not needed any more
}
// 'inside' is a shorthand property for 'vertical' and 'horizontal'
// it applies to components that have not been set explicitly
if (isset($pStyles['borders']['inside'])) {
if (isset($styleArray['borders']['inside'])) {
foreach (['vertical', 'horizontal'] as $component) {
if (!isset($pStyles['borders'][$component])) {
$pStyles['borders'][$component] = $pStyles['borders']['inside'];
if (!isset($styleArray['borders'][$component])) {
$styleArray['borders'][$component] = $styleArray['borders']['inside'];
}
}
unset($pStyles['borders']['inside']); // not needed any more
unset($styleArray['borders']['inside']); // not needed any more
}
// width and height characteristics of selection, 1, 2, or 3 (for 3 or more)
$xMax = min($rangeEnd[0] - $rangeStart[0] + 1, 3);
@ -299,7 +299,7 @@ class Style extends Supervisor
$range = $colStart . $rowStart . ':' . $colEnd . $rowEnd;
// retrieve relevant style array for region
$regionStyles = $pStyles;
$regionStyles = $styleArray;
unset($regionStyles['borders']['inside']);
// what are the inner edges of the region when looking at the selection
@ -311,8 +311,8 @@ class Style extends Supervisor
case 'top':
case 'bottom':
// should pick up 'horizontal' border property if set
if (isset($pStyles['borders']['horizontal'])) {
$regionStyles['borders'][$innerEdge] = $pStyles['borders']['horizontal'];
if (isset($styleArray['borders']['horizontal'])) {
$regionStyles['borders'][$innerEdge] = $styleArray['borders']['horizontal'];
} else {
unset($regionStyles['borders'][$innerEdge]);
}
@ -321,8 +321,8 @@ class Style extends Supervisor
case 'left':
case 'right':
// should pick up 'vertical' border property if set
if (isset($pStyles['borders']['vertical'])) {
$regionStyles['borders'][$innerEdge] = $pStyles['borders']['vertical'];
if (isset($styleArray['borders']['vertical'])) {
$regionStyles['borders'][$innerEdge] = $styleArray['borders']['vertical'];
} else {
unset($regionStyles['borders'][$innerEdge]);
}
@ -388,7 +388,7 @@ class Style extends Supervisor
foreach ($oldXfIndexes as $oldXfIndex => $dummy) {
$style = $workbook->getCellXfByIndex($oldXfIndex);
$newStyle = clone $style;
$newStyle->applyFromArray($pStyles);
$newStyle->applyFromArray($styleArray);
if ($existingStyle = $workbook->getCellXfByHashCode($newStyle->getHashCode())) {
// there is already such cell Xf in our collection
@ -432,26 +432,26 @@ class Style extends Supervisor
}
} else {
// not a supervisor, just apply the style array directly on style object
if (isset($pStyles['fill'])) {
$this->getFill()->applyFromArray($pStyles['fill']);
if (isset($styleArray['fill'])) {
$this->getFill()->applyFromArray($styleArray['fill']);
}
if (isset($pStyles['font'])) {
$this->getFont()->applyFromArray($pStyles['font']);
if (isset($styleArray['font'])) {
$this->getFont()->applyFromArray($styleArray['font']);
}
if (isset($pStyles['borders'])) {
$this->getBorders()->applyFromArray($pStyles['borders']);
if (isset($styleArray['borders'])) {
$this->getBorders()->applyFromArray($styleArray['borders']);
}
if (isset($pStyles['alignment'])) {
$this->getAlignment()->applyFromArray($pStyles['alignment']);
if (isset($styleArray['alignment'])) {
$this->getAlignment()->applyFromArray($styleArray['alignment']);
}
if (isset($pStyles['numberFormat'])) {
$this->getNumberFormat()->applyFromArray($pStyles['numberFormat']);
if (isset($styleArray['numberFormat'])) {
$this->getNumberFormat()->applyFromArray($styleArray['numberFormat']);
}
if (isset($pStyles['protection'])) {
$this->getProtection()->applyFromArray($pStyles['protection']);
if (isset($styleArray['protection'])) {
$this->getProtection()->applyFromArray($styleArray['protection']);
}
if (isset($pStyles['quotePrefix'])) {
$this->quotePrefix = $pStyles['quotePrefix'];
if (isset($styleArray['quotePrefix'])) {
$this->quotePrefix = $styleArray['quotePrefix'];
}
}
@ -533,13 +533,13 @@ class Style extends Supervisor
/**
* Set Conditional Styles. Only used on supervisor.
*
* @param Conditional[] $pValue Array of conditional styles
* @param Conditional[] $conditionalStyleArray Array of conditional styles
*
* @return $this
*/
public function setConditionalStyles(array $pValue)
public function setConditionalStyles(array $conditionalStyleArray)
{
$this->getActiveSheet()->setConditionalStyles($this->getSelectedCells(), $pValue);
$this->getActiveSheet()->setConditionalStyles($this->getSelectedCells(), $conditionalStyleArray);
return $this;
}
@ -571,20 +571,20 @@ class Style extends Supervisor
/**
* Set quote prefix.
*
* @param bool $pValue
* @param bool $quotePrefix
*
* @return $this
*/
public function setQuotePrefix($pValue)
public function setQuotePrefix($quotePrefix)
{
if ($pValue == '') {
$pValue = false;
if ($quotePrefix == '') {
$quotePrefix = false;
}
if ($this->isSupervisor) {
$styleArray = ['quotePrefix' => $pValue];
$styleArray = ['quotePrefix' => $quotePrefix];
$this->getActiveSheet()->getStyle($this->getSelectedCells())->applyFromArray($styleArray);
} else {
$this->quotePrefix = (bool) $pValue;
$this->quotePrefix = (bool) $quotePrefix;
}
return $this;
@ -628,11 +628,11 @@ class Style extends Supervisor
/**
* Set own index in style collection.
*
* @param int $pValue
* @param int $index
*/
public function setIndex($pValue): void
public function setIndex($index): void
{
$this->index = $pValue;
$this->index = $index;
}
protected function exportArray1(): array