Skip to content

Commit

Permalink
Merge pull request #11 from Jeckel-Lab/update-readme
Browse files Browse the repository at this point in the history
Update readme with contracts updates
  • Loading branch information
jeckel authored Jun 15, 2020
2 parents e3b7463 + ca4ec2e commit ade1dfd
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,18 +15,18 @@ composer require jeckel-lab/clock

## Usage

In your code, always use the ClockInterface in your services when you need to access the current time. After that, you just had to define which implementation to use according to your environement (real or fake for tests).
In your code, always use the `JeckelLab\Contract\Infrastructure\System\Clock` interface in your services when you need to access the current time. After that, you just have to define which implementation to use according to your environment (real or fake for tests).

In some framework, It can be easier to use the factory to handle the switch and inject the require configuration.
In some framework, it can be easier to use the factory to handle the switch and inject the required configuration.

### Symfony 4
### Symfony 4 and 5

With SF4 we use the internal DI system with the factory. The factory will get different parameters according to the current environment.
With SF4 and SF5 we use the internal DI system with the factory. The factory will get different parameters according to the current environment.

Configure DI with a factory in `config/services.yaml`:
```yaml
# config/services.yaml
JeckelLab\Clock\ClockInterface:
JeckelLab\Contract\Infrastructure\System\Clock:
factory: ['JeckelLab\Clock\ClockFactory', getClock]
arguments: ['%fake_clock%', '%fake_clock_file%']
```
Expand Down

0 comments on commit ade1dfd

Please sign in to comment.