Skip to content

Instantly share code, notes, and snippets.

@ahmedash95
Last active August 6, 2017 13:53
Show Gist options
  • Save ahmedash95/559c86dc5cebf6ddf00418ca35399a00 to your computer and use it in GitHub Desktop.
Save ahmedash95/559c86dc5cebf6ddf00418ca35399a00 to your computer and use it in GitHub Desktop.
<?php
interface Logger {
public function log(string $msg);
}
class Application {
private $logger;
public function getLogger(): Logger {
return $this->logger;
}
public function setLogger(Logger $logger) {
$this->logger = $logger;
}
}
$app = new Application;
$app->setLogger(new class implements Logger {
public function log(string $msg) {
print($msg);
}
});
$app->getLogger()->log("My first Log Message");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment