Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //create dependency injection container
- class FileTypeA_DI_Container implements FileType_DI_Container{
- public function getFactory(){
- return new FileAFactory();
- }
- }
- //edit the ZipFile class to accept the DI container
- class ZipFile{
- public function __construct(DI_Container $di){
- $this->di = $di;
- }
- //edit the readFiles method to make use of DI container?
- public function readFiles(){
- //loop
- $file = $this->di->getFactory()->createFile();
- //end loop
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement