The definition of DI quoted from Wikipedia states:
A. High-level modules should not depend on low-level modules. Both should depend on abstractions. B. Abstractions should not depend upon details. Details should depend upon abstractions.
I'm trying to apply that principle to my code:
class Printer{
private $logger;
function __construct(Zend_Log $logger){
$this->logger=$logger;
}
function print(){
//Some code
$this->logger->log('Logger in action ;)');
}
}
Now since why Printer
class depends on Zend_Log
which is neither an abstract class nor an interface then I'm violating the Dependency Inversion principle.
How can I fix that knowing that Zend_Log
doesn't extend an abstract class nor implement an interface?