Skip to content

Instantly share code, notes, and snippets.

@AmyStephen
Created January 24, 2013 11:21
Show Gist options
  • Save AmyStephen/4620244 to your computer and use it in GitHub Desktop.
Save AmyStephen/4620244 to your computer and use it in GitHub Desktop.
PSR-3 Static Factory Approach
<?php
use Psr\Log\LoggerInterface;
class Foo
{
private $logger;
public function __construct()
{
$this->logger = MyStaticFactory::getLog();
}
public function doSomething()
{
if ($this->logger) {
$this->logger->info('Doing work');
}
// do something useful
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment