<?php
class Config
{
protected $_logger;
public function __construct()
{
$this->_logger = new stdClass();
}
public function getLogger()
{
return $this->_logger;
}
}
class Foo
{
protected $_config = null;
public function __construct()
{
$this->_config = new Config();
}
public function execute()
{
if($this->_config->getLogger()) {
}
}
}
class Bar
{
protected $_config = null;
protected $_loggerExists = false;
public function __construct()
{
$this->_config = new stdClass();
$this->_loggerExists = true;
}
public function execute()
{
if($this->_loggerExists) {
}
}
}
$f = new Foo();
$s = microtime(true);
for($i = 0; $i < 100; $i++) {
$f->execute();
}
echo (microtime(true)-$s)."s\n";
$f = new Bar();
$s = microtime(true);
for($i = 0; $i < 100; $i++) {
$f->execute();
}
echo (microtime(true)-$s)."s\n"
sfDoctrine2Plugin already uses this logger for its debug toolbar.