Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
5 / 5
PropGuard
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
5 / 5
 __set
100.00% covered (success)
100.00%
1 / 1
2
100.00% covered (success)
100.00%
5 / 5
<?php
namespace RemexHtml;
/**
 * This is a statically configurable mechanism for preventing the setting of
 * undeclared properties on objects. The point of it is to detect programmer
 * errors.
 */
trait PropGuard {
    public static $armed = true;
    public function __set( $name, $value ) {
        if ( self::$armed ) {
            throw new \Exception( "Property \"$name\" on object of class " . get_class( $this ) .
                " is undeclared" );
        } else {
            $this->$name = $value;
        }
    }
}