public static function fromArray(array $data, $filter = false){
        $class = get_called_class();
        $object = new static();
        foreach($data as $key => $value){
            if(!$filter || property_exists($class, $key)){
                $object->$key = $value;
            }
        }
        return $object;
    }
public static function fromArray(array $data, $filter = false){
        $class = get_called_class();
        $object = new static();
        foreach($data as $key => $value){
            if(!$filter || property_exists($class, $key)){
                $object->$key = $value;
            }
        }
        return $object;
    }
public static function fromArray ( array $ data , $ filter = false ) { $ class = get_called_class ( ) ; $ object = new static ( ) ; foreach ( $ data as $ key => $ value ) { if ( ! $ filter || property_exists ( $ class , $ key ) ) { $ object -> $ key = $ value ; } } return $ object ; }
Create a Struct from an associative array
@param array $data associative array array('property'=>data)
@param bool $filter (optional) if true, $data array keys which are not defined as properties in the Struct will be ignored
@return Struct
Create a Struct from an associative array