Fix code before applying PHP CS Fixer

This commit is contained in:
Adrien Loison committed 2017-09-06 00:33:43 +02:00
1 parent 554ebf987b
commit 740fcfb8c1
21 files changed
+96 -79

No files matched your search

+1 -1
View File
@@ -26,7 +26,7 @@ class CellHelper
* Calling fillMissingArrayIndexes($dataArray, 'FILL') will return this array: ['FILL', 1, 'FILL', 3]
*
* @param array $dataArray The array to fill
* @param string|void $fillValue optional
* @param string $fillValue optional
* @return array
*/
public static function fillMissingArrayIndexes($dataArray, $fillValue = '')
@@ -175,11 +175,14 @@ class CellValueFormatter
$shouldFormatAsDate = $this->styleManager->shouldFormatNumericValueAsDate($cellStyleId);
if ($shouldFormatAsDate) {
return $this->formatExcelTimestampValue(floatval($nodeValue), $cellStyleId);
$cellValue = $this->formatExcelTimestampValue(floatval($nodeValue), $cellStyleId);
} else {
$nodeIntValue = intval($nodeValue);
return ($nodeIntValue == $nodeValue) ? $nodeIntValue : floatval($nodeValue);
$nodeFloatValue = (float) $nodeValue;
$cellValue = ((float) $nodeIntValue === $nodeFloatValue) ? $nodeIntValue : $nodeFloatValue;
}
return $cellValue;
}
/**
@@ -200,14 +203,16 @@ class CellValueFormatter
if ($nodeValue >= 1) {
// Values greater than 1 represent "dates". The value 1.0 representing the "base" date: 1900-01-01.
return $this->formatExcelTimestampValueAsDateValue($nodeValue, $cellStyleId);
$cellValue = $this->formatExcelTimestampValueAsDateValue($nodeValue, $cellStyleId);
} else if ($nodeValue >= 0) {
// Values between 0 and 1 represent "times".
return $this->formatExcelTimestampValueAsTimeValue($nodeValue, $cellStyleId);
$cellValue = $this->formatExcelTimestampValueAsTimeValue($nodeValue, $cellStyleId);
} else {
// invalid date
return null;
$cellValue = null;
}
return $cellValue;
}
/**
@@ -232,10 +237,12 @@ class CellValueFormatter
if ($this->shouldFormatDates) {
$styleNumberFormatCode = $this->styleManager->getNumberFormatCode($cellStyleId);
$phpDateFormat = DateFormatHelper::toPHPDateFormat($styleNumberFormatCode);
return $dateObj->format($phpDateFormat);
$cellValue = $dateObj->format($phpDateFormat);
} else {
return $dateObj;
$cellValue = $dateObj;
}
return $cellValue;
}
/**
@@ -261,13 +268,15 @@ class CellValueFormatter
if ($this->shouldFormatDates) {
$styleNumberFormatCode = $this->styleManager->getNumberFormatCode($cellStyleId);
$phpDateFormat = DateFormatHelper::toPHPDateFormat($styleNumberFormatCode);
return $dateObj->format($phpDateFormat);
$cellValue = $dateObj->format($phpDateFormat);
} else {
return $dateObj;
$cellValue = $dateObj;
}
} catch (\Exception $e) {
return null;
$cellValue = null;
}
return $cellValue;
}
/**
@@ -278,9 +287,7 @@ class CellValueFormatter
*/
protected function formatBooleanCellValue($nodeValue)
{
// !! is similar to boolval()
$cellValue = !!$nodeValue;
return $cellValue;
return (bool) $nodeValue;
}
/**
@@ -294,9 +301,11 @@ class CellValueFormatter
{
// Mitigate thrown Exception on invalid date-time format (http://php.net/manual/en/datetime.construct.php)
try {
return ($this->shouldFormatDates) ? $nodeValue : new \DateTime($nodeValue);
$cellValue = ($this->shouldFormatDates) ? $nodeValue : new \DateTime($nodeValue);
} catch (\Exception $e) {
return null;
$cellValue = null;
}
return $cellValue;
}
}
@@ -89,11 +89,13 @@ class CachingStrategyFactory
if ($memoryAvailable === -1) {
// if cannot get memory limit or if memory limit set as unlimited, don't trust and play safe
return ($sharedStringsUniqueCount < self::MAX_NUM_STRINGS_PER_TEMP_FILE);
$isInMemoryStrategyUsageSafe = ($sharedStringsUniqueCount < self::MAX_NUM_STRINGS_PER_TEMP_FILE);
} else {
$memoryNeeded = $sharedStringsUniqueCount * self::AMOUNT_MEMORY_NEEDED_PER_STRING_IN_KB;
return ($memoryAvailable > $memoryNeeded);
$isInMemoryStrategyUsageSafe = ($memoryAvailable > $memoryNeeded);
}
return $isInMemoryStrategyUsageSafe;
}
/**
@@ -52,7 +52,7 @@ class SheetManager
/**
* @param string $filePath Path of the XLSX file being read
* @param \Box\Spout\Common\Manager\OptionsManagerInterface $optionsManager Reader's options manager
* @param \Box\Spout\Reader\XLSX\Manager\SharedStringsManager Manages shared strings
* @param \Box\Spout\Reader\XLSX\Manager\SharedStringsManager $sharedStringsManager Manages shared strings
* @param \Box\Spout\Common\Helper\Escaper\XLSX $escaper Used to unescape XML data
* @param EntityFactory $entityFactory Factory to create entities
*/