Last active
August 6, 2017 13:53
-
-
Save ahmedash95/559c86dc5cebf6ddf00418ca35399a00 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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