Skip to content

Instantly share code, notes, and snippets.

@mbischof
Created November 15, 2013 16:26
Show Gist options
  • Save mbischof/7487193 to your computer and use it in GitHub Desktop.
Save mbischof/7487193 to your computer and use it in GitHub Desktop.
Configuration-Array accessable via dot syntax
<?php
class Configuration extends \CConfiguration
{
/**
* usage: $configuration->get('contact.person.firstname');
*/
public function get($path, $default = null)
{
$current = $this;
$p = strtok($path, '.');
while ($p !== false) {
if (!isset($current[$p])) {
return $default;
}
$current = $current[$p];
$p = strtok('.');
}
return $current;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment