Skip to content

Commit a7b3637

Browse files
committed
Documentation
1 parent 1a06341 commit a7b3637

File tree

2 files changed

+32
-4
lines changed

2 files changed

+32
-4
lines changed

README.md

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
[![version](https://img.shields.io/badge/version-1.0.0-green.svg)](https://github.com/steevanb/symfony-options-resolver/tree/1.0.0)
22
[![doctrine](https://img.shields.io/badge/symfony/options_resolver-^2.6||^3.0||^4.0-blue.svg)](https://github.com/symfony/options-resolver)
33
[![php](https://img.shields.io/badge/php-^7.1-blue.svg)](http://www.php.net)
4-
![Lines](https://img.shields.io/badge/code%20lines-XXXX-green.svg)
4+
![Lines](https://img.shields.io/badge/code%20lines-369-green.svg)
55
![Total Downloads](https://poser.pugx.org/steevanb/symfony-options-resolver/downloads)
66
[![Scrutinizer](https://scrutinizer-ci.com/g/steevanb/symfony-options-resolver/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/steevanb/symfony-options-resolver/)
77

88
### symfony-options-resolver
99

10-
Add features to Symfony [OptionsResolver](https://github.com/symfony/options-resolver) compoent.
10+
Add features to Symfony [OptionsResolver](https://github.com/symfony/options-resolver) component.
1111

1212
[Changelog](changelog.md)
1313

@@ -17,10 +17,38 @@ Add features to Symfony [OptionsResolver](https://github.com/symfony/options-res
1717
composer require "steevanb/symfony-options-resolver": "^1.0"
1818
```
1919

20-
### Examples
20+
### Examples
2121

22+
Define an optional option with a default value:
2223
```php
2324
use steevanb\SymfonyOptionsResolver\OptionsResolver
2425

26+
$optionsResolver = new OptionsResolver();
2527

28+
# Configure an optional option
29+
$optionsResolver->configureOption('foo', ['string'], ['bar', 'baz'], 'bar');
30+
31+
# Equivalent to call original OptionsResolver methods:
32+
$optionsResolver
33+
->setDefined('foo')
34+
->setAllowedTypes('foo', ['string'])
35+
->setAllowedValues('foo', ['bar', 'baz'])
36+
->setDefault('foo', 'bar');
37+
```
38+
39+
Define a required option:
40+
```php
41+
use steevanb\SymfonyOptionsResolver\OptionsResolver
42+
43+
$optionsResolver = new OptionsResolver();
44+
45+
# Configure a required option
46+
$optionsResolver->configureRequiredOption('foo', ['string'], ['bar', 'baz']);
47+
48+
# Equivalent to call original OptionsResolver methods:
49+
$optionsResolver
50+
->setDefined('foo')
51+
->setAllowedTypes('foo', ['string'])
52+
->setAllowedValues('foo', ['bar', 'baz'])
53+
->setRequired('foo');
2654
```

changelog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
### 1.0.0 - 2019-09-27
1+
### 1.0.0 - 2019-09-27
22

33
- Create `steevanb\SymfonyOptionsResolver\OptionsResolver`.
44
- Add `OptionsResolver::configureOption()`.

0 commit comments

Comments
 (0)