Skip to content

Commit

Permalink
Develop (#4)
Browse files Browse the repository at this point in the history
* Update test libs, add new test and fix some docs

* More fix to documents and formats

* Add singleton invokable string resolver

* Add singleton invokable string resolver document
  • Loading branch information
leoqbc authored Apr 11, 2024
1 parent af35cd2 commit ccd3e54
Show file tree
Hide file tree
Showing 7 changed files with 255 additions and 97 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,13 @@ use Peroxide\DependencyInjection\Invokables\Singleton;
$container = new Container([
// Dependency parent with dependency child
Dependency::class => new Singleton(fn() => new Dependency()),

ParentDependency::class => new Singleton(
fn($container) => new ParentDependency($container->get(Dependency::class))
)
),

// Singleton passing factory as reference string
ConcreteClass::class => new Singleton(ConcreteClassFactory::class)
]);
```
The ```Peroxide\DependencyInjection\Invokables\Singleton``` class serves as a wrapper to indicate to our container that we want this class to not create a new instance every time it is retrieved.
Expand Down
8 changes: 6 additions & 2 deletions README_PT.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,15 @@ use Peroxide\DependencyInjection\Container;
use Peroxide\DependencyInjection\Invokables\Singleton;

$container = new Container([
// Dependência pai com dependência filha
// Dependência pai com filha.
Dependency::class => new Singleton(fn() => new Dependency()),

ParentDependency::class => new Singleton(
fn($container) => new ParentDependency($container->get(Dependency::class))
)
),

// Singleton passando string como referencia de classe factory
ConcreteClass::class => new Singleton(ConcreteClassFactory::class)
]);
```
A classe ```Peroxide\DependencyInjection\Invokables\Singleton``` atua como um invólucro
Expand Down
3 changes: 2 additions & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
}
},
"require-dev": {
"phpunit/phpunit": "^10.3"
"phpunit/phpunit": "^10.3",
"squizlabs/php_codesniffer": "^3.9"
},
"autoload-dev": {
"psr-4": {
Expand Down
Loading

0 comments on commit ccd3e54

Please sign in to comment.