Skip to content
This repository has been archived by the owner on Jul 3, 2023. It is now read-only.

Commit

Permalink
Version 0.6.1 Beta
Browse files Browse the repository at this point in the history
Allow setting/getting of any class level variable with a publicly availa
ble get/set method
  • Loading branch information
Tom Chapman authored and Tom Chapman committed Jul 18, 2011
1 parent c984183 commit c2f8430
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion GoogleAnalyticsServerSide.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GPL
* @author Tom Chapman
* @link http://github.com/chappy84/google-analytics-server-side
* @version Beta 0.6.0
* @version Beta 0.6.1
* @example $gass = new GoogleAnalyticsServerSide();
* $gass->setAccount('UA-XXXXXXX-X')
* ->createPageView();
Expand Down Expand Up @@ -379,6 +379,13 @@ public function getOptions() {
*/
public function getOption($name) {
if (!array_key_exists($name, $this->options)) {
$methodName = 'get'.ucfirst($name);
if (method_exists($this, $methodName)) {
$reflectionMethod = new ReflectionMethod($this, $methodName);
if ($reflectionMethod->isPublic()) {
return $this->$methodName();
}
}
throw new OutOfRangeException('Option '.$name.' is not an available option.');
}
return $this->options[$name];
Expand Down Expand Up @@ -587,6 +594,15 @@ public function setOptions(array $options = array()) {
*/
public function setOption($name, $value) {
$this->getOption($name);
if (!array_key_exists($name, $this->options)) {
$methodName = 'set'.ucfirst($name);
if (method_exists($this, $methodName)) {
$reflectionMethod = new ReflectionMethod($this, $methodName);
if ($reflectionMethod->isPublic()) {
return $this->$methodName($value);
}
}
}
switch ($name) {
case 'ignoreBots':
if (!is_bool($value)) {
Expand Down

0 comments on commit c2f8430

Please sign in to comment.