From 09d9536222c51255cba8940e7449165f3f873b1d Mon Sep 17 00:00:00 2001 From: Chris Coley Date: Tue, 5 Jul 2016 15:33:30 -0700 Subject: [PATCH 1/2] This is how default parameters should be done in PHP. The other way throws PHP Warnings. --- src/zc.php | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/zc.php b/src/zc.php index df68622..bb99401 100644 --- a/src/zc.php +++ b/src/zc.php @@ -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; @@ -390,4 +390,4 @@ private function buildArray($propertyChain, $value) { return array($key => $this->buildArray($propertyChain, $value)); } } -?> \ No newline at end of file +?> From 6314733c7cc649fbd25e25f2a89c0035a99ab864 Mon Sep 17 00:00:00 2001 From: Chris Coley Date: Tue, 5 Jul 2016 15:35:28 -0700 Subject: [PATCH 2/2] If you're using namespacing and autoloading, then you have to define the namespace in the class file. --- src/zc.php | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/zc.php b/src/zc.php index bb99401..54125db 100644 --- a/src/zc.php +++ b/src/zc.php @@ -1,4 +1,7 @@