File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -42,7 +42,11 @@ class Validators
4242 'uri ' => [__CLASS__ , 'isUri ' ],
4343 'none ' => [__CLASS__ , 'isNone ' ],
4444 'type ' => [__CLASS__ , 'isType ' ],
45+ 'class ' => 'class_exists ' ,
46+ 'interface ' => 'interface_exists ' ,
4547 'identifier ' => [__CLASS__ , 'isPhpIdentifier ' ],
48+ 'file ' => 'is_file ' ,
49+ 'directory ' => 'is_dir ' ,
4650 'pattern ' => null ,
4751 'alnum ' => 'ctype_alnum ' ,
4852 'alpha ' => 'ctype_alpha ' ,
Original file line number Diff line number Diff line change @@ -321,6 +321,32 @@ test(function () {
321321});
322322
323323
324+ test (function () {
325+ Assert::true (Validators::is ('rimmer ' , 'class ' ));
326+ Assert::false (Validators::is ('kryton ' , 'class ' ));
327+ Assert::false (Validators::is ('1 ' , 'class ' ));
328+ });
329+
330+
331+ test (function () {
332+ Assert::false (Validators::is ('rimmer ' , 'interface ' ));
333+ Assert::true (Validators::is ('kryton ' , 'interface ' ));
334+ Assert::false (Validators::is ('1 ' , 'interface ' ));
335+ });
336+
337+
338+ test (function () {
339+ Assert::true (Validators::is (__FILE__ , 'file ' ));
340+ Assert::false (Validators::is (__FILE__ . 'xx ' , 'class ' ));
341+ });
342+
343+
344+ test (function () {
345+ Assert::true (Validators::is (__DIR__ , 'directory ' ));
346+ Assert::false (Validators::is (__DIR__ . 'xx ' , 'directory ' ));
347+ });
348+
349+
324350test (function () {
325351 Assert::true (Validators::is ('Item ' , 'identifier ' ));
326352 Assert::false (Validators::is ('0Item ' , 'identifier ' ));
You can’t perform that action at this time.
0 commit comments