|
@@ -3,11 +3,15 @@
|
|
|
|
|
|
class Filter {
|
|
class Filter {
|
|
private static $filters = [];
|
|
private static $filters = [];
|
|
- private $name;
|
|
|
|
|
|
+ public $name;
|
|
private $filter;
|
|
private $filter;
|
|
- private function __construct(string $name, string $filter){
|
|
|
|
- $this->name = $name;
|
|
|
|
- self::$filters[$name] = $this;
|
|
|
|
|
|
+ private $sprintf;
|
|
|
|
+ private function __construct(string $name = null, string $filter){
|
|
|
|
+ $this->filter = $filter;
|
|
|
|
+ if(!is_null($name)){
|
|
|
|
+ $this->name = $name;
|
|
|
|
+ self::$filters[$name] = $this;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
public function name(){
|
|
public function name(){
|
|
return $this->name;
|
|
return $this->name;
|
|
@@ -22,12 +26,18 @@
|
|
return self::$filters[$name];
|
|
return self::$filters[$name];
|
|
}
|
|
}
|
|
public static function add(string $name, string $filter){
|
|
public static function add(string $name, string $filter){
|
|
|
|
+ if(is_null($name)){
|
|
|
|
+ throw new Exception("Named filters cannot have a null name");
|
|
|
|
+ }
|
|
if(isset(self::$filters[$name])){
|
|
if(isset(self::$filters[$name])){
|
|
throw new \Exception("Filter {$name} is already defined");
|
|
throw new \Exception("Filter {$name} is already defined");
|
|
}
|
|
}
|
|
return new Filter($name, $filter);
|
|
return new Filter($name, $filter);
|
|
}
|
|
}
|
|
|
|
+ public static function create(string $filter){
|
|
|
|
+ return new Filter(null, $filter);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
Filter::add('not null', 'is not null');
|
|
Filter::add('not null', 'is not null');
|
|
Filter::add('null', 'is null');
|
|
Filter::add('null', 'is null');
|
|
-?>
|
|
|
|
|
|
+?>
|