php classes… validation

前端 未结 3 539
-上瘾入骨i
-上瘾入骨i 2020-12-17 01:54

im am making a php validation class with sub classes that extend it, eg, mobile, suburb, credit_card, ect

so, the idea is you can call

$validation =          


        
3条回答
  •  臣服心动
    2020-12-17 02:26

    ...
    public function type($type) {
        return new self($type);
    }
    ...
    

    Note: This one every time returns a new instance of your Validator class so it would be a better idea to use the Factory pattern as Dennis suggested or not to tie the new Validator to the type() method.

提交回复
热议问题