Skip to content

Instantly share code, notes, and snippets.

@phpwax
phpwax / gist:4140042
Created November 24, 2012 15:08 — forked from rossriley/Configuration.php
Trait for defaults and settings
<?php
trait StaticDefaults{
protected static $_defaults = [];
public function __get($key){
if(is_callable($func = self::$_defaults[$key])) return $func();
return $func;
}
static public function defaults($defaults){
@phpwax
phpwax / gist:4137812
Created November 24, 2012 00:22
static default generic trait
<?php
trait StaticFallback{
public static $_fallback;
public function __get($key){return self::$_fallback[$key];}
public static function fallback($key, $value){return self::$_fallback[$key] = $value;}
}
class Model{
use StaticFallback;
}