<?php
class X {
private $regras = [
"required"=>true,
"email"=>true
];
public $filter = [
'preco' => 'required;double(1,4)',
'email' => 'required;email',
'bilhetes' => 'required;min:0'
];
public function bootFilterPost() {
foreach ($this->filter as $key => $value):
foreach ($arr as $a):
$this->postRules[$key][$a] = $this->regras[$a];
elseif (strpos($a, "(") !== false): $this->postRules[$key][$split[0]] = "(" . $split[1];
elseif (strpos($a, ":") !== false): $this->postRules[$key][$split[0]] = $split[1];
endif;
endforeach;
endforeach;
}
};
$x = new X;
$x->bootFilterPost();
PD9waHAKCmNsYXNzIFggewogICAgcHJpdmF0ZSAkcmVncmFzID0gWwogICAgICAgICJyZXF1aXJlZCI9PnRydWUsIAogICAgICAgICJlbWFpbCI9PnRydWUKICAgIF07CiAgICAKICAgIHB1YmxpYyAkZmlsdGVyID0gWwogICAgICAgICdwcmVjbycgPT4gJ3JlcXVpcmVkO2RvdWJsZSgxLDQpJywKICAgICAgICAnZW1haWwnID0+ICdyZXF1aXJlZDtlbWFpbCcsCiAgICAgICAgJ2JpbGhldGVzJyA9PiAncmVxdWlyZWQ7bWluOjAnCiAgICBdOwogICAgCiAgICBwdWJsaWMgZnVuY3Rpb24gYm9vdEZpbHRlclBvc3QoKSB7CiAgICAKICAgICAgICBmb3JlYWNoICgkdGhpcy0+ZmlsdGVyIGFzICRrZXkgPT4gJHZhbHVlKToKICAgICAgICAgICAgJGFyciA9IHByZWdfc3BsaXQoJy8oOykvJywgJHZhbHVlKTsKICAgICAgICAgICAgCiAgICAgICAgICAgIGZvcmVhY2ggKCRhcnIgYXMgJGEpOgoKICAgICAgICAgICAgICAgIGlmIChhcnJheV9rZXlfZXhpc3RzICgkYSwgJHRoaXMtPnJlZ3JhcykpOgogICAgICAgICAgICAgICAgICAgICR0aGlzLT5wb3N0UnVsZXNbJGtleV1bJGFdID0gJHRoaXMtPnJlZ3Jhc1skYV07CiAgICAgICAgICAgICAgICBlbHNlaWYgKHN0cnBvcygkYSwgIigiKSAhPT0gZmFsc2UpOgogICAgICAgICAgICAgICAgICAgICRzcGxpdCA9IGV4cGxvZGUoIigiLCAkYSk7CiAgICAgICAgICAgICAgICAgICAgJHRoaXMtPnBvc3RSdWxlc1ska2V5XVskc3BsaXRbMF1dID0gIigiIC4gJHNwbGl0WzFdOyAKICAgICAgICAgICAgICAgIGVsc2VpZiAoc3RycG9zKCRhLCAiOiIpICE9PSBmYWxzZSk6CiAgICAgICAgICAgICAgICAgICAgJHNwbGl0ID0gZXhwbG9kZSgiOiIsICRhKTsKICAgICAgICAgICAgICAgICAgICAkdGhpcy0+cG9zdFJ1bGVzWyRrZXldWyRzcGxpdFswXV0gPSAkc3BsaXRbMV07IAogICAgICAgICAgICAgICAgZW5kaWY7CiAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgIAogICAgICAgICAgICBlbmRmb3JlYWNoOwogICAgICAgIGVuZGZvcmVhY2g7CiAgICAKICAgICAgICB2YXJfZHVtcCgkdGhpcy0+cG9zdFJ1bGVzKTsKICAgIH0KfTsKCgoKCiR4ID0gbmV3IFg7CgokeC0+Ym9vdEZpbHRlclBvc3QoKTs=