Skip to content

Commit

Permalink
Removed commented code and replaced Container::resolve_service to Con…
Browse files Browse the repository at this point in the history
…tainer::get
  • Loading branch information
renakdup committed Nov 28, 2023
1 parent 34cfd95 commit cb87af7
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ $container->set('config.', ['one', 'two, 'three']);
- [ ] Add ability creating new instance of service every time
- [ ] Add supporting Code Driven IoC
- [ ] Add singleton getting for Container
- [ ] Add descriptions in the code for functions.
- [ ] Set definitions via constuctor
- [ ] Add `remove` method?
- [ ] Integrate CI
- [ ] Add badges with tests passed
Expand Down
12 changes: 1 addition & 11 deletions src/Container.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
* Simple PHP DI Container (DIC) for WordPress with auto-wiring allows
* you easily use it in your plugins and themes.
*
* @version 0.2
* Author: Andrei Pisarevskii
* Author Email: [email protected]
* Author Site: https://wp-yoda.com/en/
*
* Version: 0.2
* Source Code: https://github.com/renakdup/simple-wordpress-dic
*
* Licence: MIT License
Expand Down Expand Up @@ -75,26 +75,16 @@ interface NotFoundExceptionInterface extends ContainerExceptionInterface {}
class Container implements ContainerInterface {
protected array $services = [];

// protected array $resolved_services = [];

public function set( string $id, $service ): void {
$this->services[ $id ] = $service;
// unset( $this->resolved_services[ $id ] );
}

/**
* {@inheritdoc}
*/
public function get( string $id ) {
// if ( isset( $this->resolved_services[ $id ] ) || array_key_exists( $id, $this->resolved_services ) ) {
// return $this->resolved_services[ $id ];
// }


$resolved_service = $this->resolve_service( $this->has( $id ) ? $this->services[ $id ] : $id );

// $this->resolved_services[ $id ] = $resolved_service;

return $resolved_service;
}

Expand Down

0 comments on commit cb87af7

Please sign in to comment.