Skip to content

Commit

Permalink
php-cs-fixer
Browse files Browse the repository at this point in the history
  • Loading branch information
CrazyBite committed May 17, 2017
1 parent 64deb5f commit a3355c2
Show file tree
Hide file tree
Showing 2 changed files with 194 additions and 188 deletions.
54 changes: 30 additions & 24 deletions src/PhpSpreadsheet/Chart/DataSeriesValues.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ class DataSeriesValues
const DATASERIES_TYPE_STRING = 'String';
const DATASERIES_TYPE_NUMBER = 'Number';

private static $dataTypeValues = [
private static $dataTypeValues = array(
self::DATASERIES_TYPE_STRING,
self::DATASERIES_TYPE_NUMBER,
];
);

/**
* Series Data Type.
Expand Down Expand Up @@ -74,27 +74,30 @@ class DataSeriesValues
*
* @var array of mixed
*/
private $dataValues = [];
private $dataValues = array();

/**
* Create a new DataSeriesValues object.
*
* @param mixed $dataType
* Fill color.
* Fill color
*
* @var string
*/
private $fillColor;

/**
* Create a new DataSeriesValues object
* @param string $dataSource
* Create a new DataSeriesValues object.
*
* @param string $dataSource
* @param null|mixed $formatCode
* @param mixed $pointCount
* @param mixed $dataValues
* @param mixed $pointCount
* @param mixed $dataValues
* @param null|mixed $marker
* @param mixed $dataType
* @param null|mixed $color
*/
public function __construct($dataType = self::DATASERIES_TYPE_NUMBER, $dataSource = null, $formatCode = null, $pointCount = 0, $dataValues = [], $marker = null, $color = null)
public function __construct($dataType = self::DATASERIES_TYPE_NUMBER, $dataSource = null, $formatCode = null, $pointCount = 0, $dataValues = array(), $marker = null, $color = null)
{
$this->setDataType($dataType);
$this->dataSource = $dataSource;
Expand All @@ -119,19 +122,19 @@ public function getDataType()
* Set Series Data Type.
*
* @param string $dataType Datatype of this data series
* Typical values are:
* \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues::DATASERIES_TYPE_STRING
* Normally used for axis point values
* \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues::DATASERIES_TYPE_NUMBER
* Normally used for chart data values
* Typical values are:
* \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues::DATASERIES_TYPE_STRING
* Normally used for axis point values
* \PhpOffice\PhpSpreadsheet\Chart\DataSeriesValues::DATASERIES_TYPE_NUMBER
* Normally used for chart data values
*
* @throws Exception
*
* @return DataSeriesValues
*/
public function setDataType($dataType)
{
if (!in_array($dataType, self::$dataTypeValues)) {
if (!in_array($dataType, self::$dataTypeValues, true)) {
throw new Exception('Invalid datatype for chart data series values');
}
$this->dataType = $dataType;
Expand Down Expand Up @@ -233,22 +236,25 @@ public function getFillColor()
}

/**
* Set fill color for series
* Set fill color for series.
*
* @param string HEX color
* @return DataSeriesValues
* @param mixed $color
*
* @return DataSeriesValues
*/
public function setFillColor($color)
{
if (!preg_match('/^[a-f0-9]{6}$/i', $color)) {
throw new Exception('Invalid hex color for chart series');
}
$this->fillColor = $color;

return $this;
}

/**
* Identify if the Data Series is a multi-level or a simple series
* Identify if the Data Series is a multi-level or a simple series.
*
* @return bool|null
*/
Expand Down Expand Up @@ -294,9 +300,9 @@ public function getDataValues()
public function getDataValue()
{
$count = count($this->dataValues);
if ($count == 0) {
if ($count === 0) {
return null;
} elseif ($count == 1) {
} elseif ($count === 1) {
return $this->dataValues[0];
}

Expand Down Expand Up @@ -324,15 +330,15 @@ public function refresh(\PhpOffice\PhpSpreadsheet\Worksheet $worksheet, $flatten
$calcEngine = \PhpOffice\PhpSpreadsheet\Calculation::getInstance($worksheet->getParent());
$newDataValues = \PhpOffice\PhpSpreadsheet\Calculation::unwrapResult(
$calcEngine->_calculateFormulaValue(
'=' . $this->dataSource,
'='.$this->dataSource,
null,
$worksheet->getCell('A1')
)
);
if ($flatten) {
$this->dataValues = \PhpOffice\PhpSpreadsheet\Calculation\Functions::flattenArray($newDataValues);
foreach ($this->dataValues as &$dataValue) {
if ((!empty($dataValue)) && ($dataValue[0] == '#')) {
if ((!empty($dataValue)) && ($dataValue[0] === '#')) {
$dataValue = 0.0;
}
}
Expand All @@ -344,12 +350,12 @@ public function refresh(\PhpOffice\PhpSpreadsheet\Worksheet $worksheet, $flatten
}

$dimensions = \PhpOffice\PhpSpreadsheet\Cell::rangeDimension(str_replace('$', '', $cellRange));
if (($dimensions[0] == 1) || ($dimensions[1] == 1)) {
if (($dimensions[0] === 1) || ($dimensions[1] === 1)) {
$this->dataValues = \PhpOffice\PhpSpreadsheet\Calculation\Functions::flattenArray($newDataValues);
} else {
$newArray = array_values(array_shift($newDataValues));
foreach ($newArray as $i => $newDataSet) {
$newArray[$i] = [$newDataSet];
$newArray[$i] = array($newDataSet);
}

foreach ($newDataValues as $newDataSet) {
Expand Down
Loading

0 comments on commit a3355c2

Please sign in to comment.