1
1
# TypeGuard - PHP type validation partly inspired by [ Ceylon Union and Intersection types] ( https://ceylon-lang.org/documentation/1.3/tour/types/ )
2
2
3
- [ ![ Build Status] ( https://travis-ci.com/Sevavietl /TypeGuard.svg?branch=master )] ( https://travis-ci.com/Sevavietl /TypeGuard )
4
- [ ![ Coverage Status] ( https://coveralls.io/repos/github/Sevavietl /TypeGuard/badge.svg )] ( https://coveralls.io/github/Sevavietl /TypeGuard )
3
+ [ ![ Build Status] ( https://travis-ci.com/ThoroughPHP /TypeGuard.svg?branch=master )] ( https://travis-ci.com/ThoroughPHP /TypeGuard )
4
+ [ ![ Coverage Status] ( https://coveralls.io/repos/github/ThoroughPHP /TypeGuard/badge.svg )] ( https://coveralls.io/github/ThoroughPHP /TypeGuard )
5
5
[ ![ License: MIT] ( https://img.shields.io/badge/License-MIT-yellow.svg )] ( https://opensource.org/licenses/MIT )
6
6
[ ![ PHPStan] ( https://img.shields.io/badge/PHPStan-enabled-brightgreen.svg?style=flat )] ( https://github.com/phpstan/phpstan )
7
7
@@ -12,32 +12,32 @@ TypeGuard can validate:
12
12
- Scalar types: ` string ` , ` integer ` , etc.:
13
13
14
14
``` php
15
- (new \ TypeGuard\Guard ('string'))->match('foo'); // => true
15
+ (new TypeGuard('string'))->match('foo'); // => true
16
16
```
17
17
18
18
- Object types: ` ArrayAccess ` , ` stdClass ` , etc.:
19
19
20
20
``` php
21
- (new \ TypeGuard\Guard ('stdClass'))->match(new stdClass()); // => true
21
+ (new TypeGuard('stdClass'))->match(new stdClass()); // => true
22
22
```
23
23
24
24
- Union types: ` string|integer ` :
25
25
26
26
``` php
27
- $guard = new \ TypeGuard\Guard ('string|integer');
27
+ $guard = new TypeGuard('string|integer');
28
28
$guard->match('foo'); // => true
29
29
$guard->match(1); // => true
30
30
```
31
31
32
32
- Intersection types: ` ArrayAccess&Countable ` :
33
33
34
34
``` php
35
- (new \ TypeGuard\Guard ('ArrayAccess&Countable'))->match(new ArrayIterator()); // => true
35
+ (new TypeGuard('ArrayAccess&Countable'))->match(new ArrayIterator()); // => true
36
36
```
37
37
38
38
- Optional types: ` ?string ` :
39
39
40
40
``` php
41
- (new \ TypeGuard\Guard ('?string'))->match(null); // => true
41
+ (new TypeGuard('?string'))->match(null); // => true
42
42
```
43
43
0 commit comments