Advertisement
Guest User

Untitled

a guest
Nov 29th, 2013
130
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.50 KB | None | 0 0
  1. <?php
  2. //create dependency injection container
  3. class FileTypeA_DI_Container implements FileType_DI_Container{
  4.   public function getFactory(){
  5.     return new FileAFactory();
  6.   }
  7. }
  8.  
  9. //edit the ZipFile class to accept the DI container
  10. class ZipFile{
  11.   public function __construct(DI_Container $di){
  12.     $this->di = $di;
  13.   }
  14.  
  15.   //edit the readFiles method to make use of DI container?
  16.   public function readFiles(){
  17.     //loop
  18.     $file = $this->di->getFactory()->createFile();
  19.     //end loop
  20.   }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement