Skip to content

Instantly share code, notes, and snippets.

@willianmano
Created April 5, 2016 17:35
Show Gist options
  • Save willianmano/62b8662cfcba137631647140a47e5c93 to your computer and use it in GitHub Desktop.
Save willianmano/62b8662cfcba137631647140a47e5c93 to your computer and use it in GitHub Desktop.
<?php
require_once('vendor/autoload.php');
use Logger\LoggerLaravel;
$logger = new LoggerLaravel();
if($logger instanceof \Logger\LoggerAbstract) {
echo 'eh instanceof \Logger\LoggerAbstract<br>';
}
if($logger instanceof \Logger\LoggerInterface) {
echo 'eh instanceof \Logger\LoggerInterface';
}
<?php
namespace Logger;
abstract class LoggerAbstract implements LoggerInterface {
protected $prefix = "";
protected function getStrToLog($str) {
return $this->prefix . " - " . $str;
}
public function setPrefix($prefix) {
$this->prefix = $prefix;
}
}
<?php
namespace Logger;
interface LoggerInterface {
public function alert($error, $contextInfo = []);
}
<?php
namespace Logger;
class LoggerLaravel extends LoggerAbstract {
public function alert($error, $contextInfo = []) {
echo 'Alert... error...';
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment