Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
norberttech committed Apr 18, 2014
1 parent 7ab82eb commit 5ae34e3
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,33 @@

[![Build Status](https://travis-ci.org/defrag/php-matcher.svg)](https://travis-ci.org/defrag/php-matcher)

##Installation

Add to your composer.json

```
require: {
"defrag/php-matcher": "dev-master"
}
```

From now you should be able to use global function ``match($value, $pattern)``

##Example usage

### Scalar matching

```php
<?php

match(1, 1);
match('string', 'string')
```

### Type matching

```php
<?php

match(1, '@integer@');
match('Norbert', '@string@');
Expand All @@ -27,20 +42,26 @@ match(true, '@boolean@');
### Wildcard

```php
<?php

match(1, '@*@');
match(new \stdClass(), '@wildcard@');
```

### Expression matching

```php
<?php

match(new \DateTime('2014-04-01'), "expr(value.format('Y-m-d') == '2014-04-01'");
match("Norbert", "expr(value === 'Norbert')");
```

### Array matching

```php
<?php

match(
array(
'users' => array(
Expand Down Expand Up @@ -85,6 +106,8 @@ match(


```php
<?php

match(
'{
"users":[
Expand Down

0 comments on commit 5ae34e3

Please sign in to comment.