Skip to content

Commit

Permalink
This is how default parameters should be done in PHP. The other way t…
Browse files Browse the repository at this point in the history
…hrows PHP Warnings.
  • Loading branch information
ccoley committed Jul 5, 2016
1 parent ffbea01 commit 09d9536
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/zc.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,12 @@ class ZC {
private $fieldNames = array();
private $xAxisTitle = "";

public function __construct($id, $cType, $theme, $width, $height) {
public function __construct($id, $cType = 'area', $theme = 'light', $width = '100%', $height = '400') {
$this->chartId = $id;
$this->chartType = is_null($cType) ? 'area' : $cType;
$this->theme = is_null($theme) ? 'light' : $theme;
$this->width = is_null($width) ? '100%' : $width;
$this->height = is_null($height) ? '400' : $height;
$this->chartType = $cType;
$this->theme = $theme;
$this->width = $width;
$this->height = $height;

// Setting the chart type, this is not a top level function like width, height, theme, and id
$this->config['type'] = $this->chartType;
Expand Down Expand Up @@ -390,4 +390,4 @@ private function buildArray($propertyChain, $value) {
return array($key => $this->buildArray($propertyChain, $value));
}
}
?>
?>

0 comments on commit 09d9536

Please sign in to comment.