<?php
interface Log {
public function alert($message);
}
class EchoLog implements Log {
public function alert($message) {
echo $message;
}
}
class TestLog {
private $log;
public function __construct(Log $log) {
$this->log = $log;
}
public function run() {
$this->log->alert('This is an alert');
}
}
$testLog = new TestLog(new EchoLog());
$testLog->run();