Simplify some conditions and ternary expressions

This commit is contained in:
Gabriel Caruso 2018-11-04 19:51:01 -02:00 committed by Adrien Crivelli
parent 2fce5c4706
commit f42adb0daf
5 changed files with 12 additions and 12 deletions

View File

@ -1090,7 +1090,7 @@ class DateTime
return $startDate; return $startDate;
} }
$decrementing = ($endDays < 0) ? true : false; $decrementing = $endDays < 0;
// Adjust the start date if it falls over a weekend // Adjust the start date if it falls over a weekend

View File

@ -229,7 +229,7 @@ class JpGraph implements IRenderer
// Rotate for bar rather than column chart // Rotate for bar rather than column chart
$rotation = $this->chart->getPlotArea()->getPlotGroupByIndex(0)->getPlotDirection(); $rotation = $this->chart->getPlotArea()->getPlotGroupByIndex(0)->getPlotDirection();
$reverse = ($rotation == 'bar') ? true : false; $reverse = $rotation == 'bar';
$xAxisLabel = $this->chart->getXAxisLabel(); $xAxisLabel = $this->chart->getXAxisLabel();
if ($xAxisLabel !== null) { if ($xAxisLabel !== null) {

View File

@ -205,7 +205,7 @@ class NamedRange
public function setScope(Worksheet $value = null) public function setScope(Worksheet $value = null)
{ {
$this->scope = $value; $this->scope = $value;
$this->localOnly = ($value == null) ? false : true; $this->localOnly = $value != null;
return $this; return $this;
} }

View File

@ -432,7 +432,7 @@ class Gnumeric extends BaseReader
break; break;
case '20': // Boolean case '20': // Boolean
$type = DataType::TYPE_BOOL; $type = DataType::TYPE_BOOL;
$cell = ($cell == 'TRUE') ? true : false; $cell = $cell == 'TRUE';
break; break;
case '30': // Integer case '30': // Integer
@ -536,8 +536,8 @@ class Gnumeric extends BaseReader
break; break;
} }
$styleArray['alignment']['wrapText'] = ($styleAttributes['WrapText'] == '1') ? true : false; $styleArray['alignment']['wrapText'] = $styleAttributes['WrapText'] == '1';
$styleArray['alignment']['shrinkToFit'] = ($styleAttributes['ShrinkToFit'] == '1') ? true : false; $styleArray['alignment']['shrinkToFit'] = $styleAttributes['ShrinkToFit'] == '1';
$styleArray['alignment']['indent'] = ((int) ($styleAttributes['Indent']) > 0) ? $styleAttributes['indent'] : 0; $styleArray['alignment']['indent'] = ((int) ($styleAttributes['Indent']) > 0) ? $styleAttributes['indent'] : 0;
$RGB = self::parseGnumericColour($styleAttributes['Fore']); $RGB = self::parseGnumericColour($styleAttributes['Fore']);
@ -635,9 +635,9 @@ class Gnumeric extends BaseReader
$fontAttributes = $styleRegion->Style->Font->attributes(); $fontAttributes = $styleRegion->Style->Font->attributes();
$styleArray['font']['name'] = (string) $styleRegion->Style->Font; $styleArray['font']['name'] = (string) $styleRegion->Style->Font;
$styleArray['font']['size'] = (int) ($fontAttributes['Unit']); $styleArray['font']['size'] = (int) ($fontAttributes['Unit']);
$styleArray['font']['bold'] = ($fontAttributes['Bold'] == '1') ? true : false; $styleArray['font']['bold'] = $fontAttributes['Bold'] == '1';
$styleArray['font']['italic'] = ($fontAttributes['Italic'] == '1') ? true : false; $styleArray['font']['italic'] = $fontAttributes['Italic'] == '1';
$styleArray['font']['strikethrough'] = ($fontAttributes['StrikeThrough'] == '1') ? true : false; $styleArray['font']['strikethrough'] = $fontAttributes['StrikeThrough'] == '1';
switch ($fontAttributes['Underline']) { switch ($fontAttributes['Underline']) {
case '1': case '1':
$styleArray['font']['underline'] = Font::UNDERLINE_SINGLE; $styleArray['font']['underline'] = Font::UNDERLINE_SINGLE;
@ -714,7 +714,7 @@ class Gnumeric extends BaseReader
$columnAttributes = $columnOverride->attributes(); $columnAttributes = $columnOverride->attributes();
$column = $columnAttributes['No']; $column = $columnAttributes['No'];
$columnWidth = $columnAttributes['Unit'] / 5.4; $columnWidth = $columnAttributes['Unit'] / 5.4;
$hidden = ((isset($columnAttributes['Hidden'])) && ($columnAttributes['Hidden'] == '1')) ? true : false; $hidden = (isset($columnAttributes['Hidden'])) && ($columnAttributes['Hidden'] == '1');
$columnCount = (isset($columnAttributes['Count'])) ? $columnAttributes['Count'] : 1; $columnCount = (isset($columnAttributes['Count'])) ? $columnAttributes['Count'] : 1;
while ($c < $column) { while ($c < $column) {
$spreadsheet->getActiveSheet()->getColumnDimension(Coordinate::stringFromColumnIndex($c + 1))->setWidth($defaultWidth); $spreadsheet->getActiveSheet()->getColumnDimension(Coordinate::stringFromColumnIndex($c + 1))->setWidth($defaultWidth);
@ -744,7 +744,7 @@ class Gnumeric extends BaseReader
$rowAttributes = $rowOverride->attributes(); $rowAttributes = $rowOverride->attributes();
$row = $rowAttributes['No']; $row = $rowAttributes['No'];
$rowHeight = $rowAttributes['Unit']; $rowHeight = $rowAttributes['Unit'];
$hidden = ((isset($rowAttributes['Hidden'])) && ($rowAttributes['Hidden'] == '1')) ? true : false; $hidden = (isset($rowAttributes['Hidden'])) && ($rowAttributes['Hidden'] == '1');
$rowCount = (isset($rowAttributes['Count'])) ? $rowAttributes['Count'] : 1; $rowCount = (isset($rowAttributes['Count'])) ? $rowAttributes['Count'] : 1;
while ($r < $row) { while ($r < $row) {
++$r; ++$r;

View File

@ -3059,6 +3059,6 @@ class Worksheet implements IComparable
*/ */
public function hasCodeName() public function hasCodeName()
{ {
return !($this->codeName === null); return $this->codeName !== null;
} }
} }