Skip to content

Commit

Permalink
Fix and add more examples in readme
Browse files Browse the repository at this point in the history
  • Loading branch information
MAXakaWIZARD committed Apr 29, 2015
1 parent 58fe6e9 commit 6e7181f
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,43 @@ This package is compliant with [PSR-4](http://www.php-fig.org/psr/4/), [PSR-1](h
If you notice compliance oversights, please send a patch via pull request.

## Usage
Function as callback:
```php
function processItem (array $item)
function processItem(array $item)
{
print_r($item);
}

$parser = new \JsonStreamingParser\Parser('/path/to/file.json', 'processItem');
$parser = new \JsonCollectionParser\Parser();
$parser->parse('/path/to/file.json', 'processItem');
```

Static method as callback:
```php
class ItemProcessor {
public static function process(array $item)
{
print_r($item);
}
}

$parser = new \JsonCollectionParser\Parser();
$parser->parse('/path/to/file.json', array('ItemProcessor', 'process'));
```


Instance method as callback:
```php
class ItemProcessor {
public function process(array $item)
{
print_r($item);
}
}

$parser = new \JsonCollectionParser\Parser();
$processor = new \ItemProcessor();
$parser->parse('/path/to/file.json', array($processor, 'process'));
```

## License
Expand Down

0 comments on commit 6e7181f

Please sign in to comment.