Skip to content

Commit 2d4159e

Browse files
committed
Added Config::__construct() for convenience
1 parent 8a9744a commit 2d4159e

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

src/GoogleAnalytics/Config.php

+16
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,22 @@ class Config {
133133
protected $anonymizeIpAddresses = false;
134134

135135

136+
/**
137+
* @param array $properties
138+
*/
139+
public function __construct(array $properties = array()) {
140+
foreach($properties as $property => $value) {
141+
// PHP doesn't care about case in method names
142+
$setterMethod = 'set' . $property;
143+
144+
if(method_exists($this, $setterMethod)) {
145+
$this->$setterMethod($value);
146+
} else {
147+
return Tracker::_raiseError('There is no setting "' . $property . '".', __METHOD__);
148+
}
149+
}
150+
}
151+
136152
/**
137153
* @return int See self::ERROR_SEVERITY_* constants
138154
*/

0 commit comments

Comments
 (0)