Skip to content

Commit

Permalink
Added minor improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
mariuszkrzaczkowski committed Mar 22, 2018
1 parent 5f49a5e commit adfc6e9
Show file tree
Hide file tree
Showing 86 changed files with 8,392 additions and 8,330 deletions.
80 changes: 40 additions & 40 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
{
"name": "maximebf/debugbar",
"description": "Debug bar in the browser for php application",
"keywords": ["debug", "debugbar"],
"homepage": "https://github.com/maximebf/php-debugbar",
"type": "library",
"license": "MIT",
"authors": [
{
"name": "Maxime Bouroumeau-Fuseau",
"email": "[email protected]",
"homepage": "http://maximebf.com"
},
{
"name": "Barry vd. Heuvel",
"email": "[email protected]"
}
],
"require": {
"php": ">=5.3.0",
"psr/log": "^1.0",
"symfony/var-dumper": "^2.6|^3.0"
},
"require-dev": {
"phpunit/phpunit": "^4.0|^5.0"
},
"autoload": {
"psr-4": {
"DebugBar\\": "src/DebugBar/"
}
},
"suggest": {
"kriswallsmith/assetic": "The best way to manage assets",
"monolog/monolog": "Log using Monolog",
"predis/predis": "Redis storage"
},
"extra": {
"branch-alias": {
"dev-master": "1.13-dev"
}
}
"name": "yetiforce/debugbar",
"description": "Debug bar in the browser for php application",
"keywords": ["debug", "debugbar"],
"homepage": "https://github.com/maximebf/php-debugbar",
"type": "library",
"license": "MIT",
"authors": [
{
"name": "Maxime Bouroumeau-Fuseau",
"email": "[email protected]",
"homepage": "http://maximebf.com"
},
{
"name": "Barry vd. Heuvel",
"email": "[email protected]"
}
],
"require": {
"php": ">=5.3.0",
"psr/log": "^1.0",
"symfony/var-dumper": "^2.6|^3.0"
},
"require-dev": {
"phpunit/phpunit": "^4.0|^5.0"
},
"autoload": {
"psr-4": {
"DebugBar\\": "src/DebugBar/"
}
},
"suggest": {
"kriswallsmith/assetic": "The best way to manage assets",
"monolog/monolog": "Log using Monolog",
"predis/predis": "Redis storage"
},
"extra": {
"branch-alias": {
"dev-master": "1.13-dev"
}
}
}
79 changes: 40 additions & 39 deletions src/DebugBar/Bridge/CacheCacheCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
use Monolog\Logger;

/**
* Collects CacheCache operations
* Collects CacheCache operations.
*
* http://maximebf.github.io/CacheCache/
*
Expand All @@ -29,47 +29,48 @@
*/
class CacheCacheCollector extends MonologCollector
{
protected $logger;
protected $logger;

/**
* CacheCacheCollector constructor.
* @param Cache|null $cache
* @param Logger|null $logger
* @param bool $level
* @param bool $bubble
*/
public function __construct(Cache $cache = null, Logger $logger = null, $level = Logger::DEBUG, $bubble = true)
{
parent::__construct(null, $level, $bubble);
/**
* CacheCacheCollector constructor.
*
* @param Cache|null $cache
* @param Logger|null $logger
* @param bool $level
* @param bool $bubble
*/
public function __construct(Cache $cache = null, Logger $logger = null, $level = Logger::DEBUG, $bubble = true)
{
parent::__construct(null, $level, $bubble);

if ($logger === null) {
$logger = new Logger('Cache');
}
$this->logger = $logger;
if ($logger === null) {
$logger = new Logger('Cache');
}
$this->logger = $logger;

if ($cache !== null) {
$this->addCache($cache);
}
}
if ($cache !== null) {
$this->addCache($cache);
}
}

/**
* @param Cache $cache
*/
public function addCache(Cache $cache)
{
$backend = $cache->getBackend();
if (!($backend instanceof LoggingBackend)) {
$backend = new LoggingBackend($backend, $this->logger);
}
$cache->setBackend($backend);
$this->addLogger($backend->getLogger());
}
/**
* @param Cache $cache
*/
public function addCache(Cache $cache)
{
$backend = $cache->getBackend();
if (!($backend instanceof LoggingBackend)) {
$backend = new LoggingBackend($backend, $this->logger);
}
$cache->setBackend($backend);
$this->addLogger($backend->getLogger());
}

/**
* @return string
*/
public function getName()
{
return 'cache';
}
/**
* @return string
*/
public function getName()
{
return 'cache';
}
}
152 changes: 77 additions & 75 deletions src/DebugBar/Bridge/DoctrineCollector.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
use Doctrine\ORM\EntityManager;

/**
* Collects Doctrine queries
* Collects Doctrine queries.
*
* http://doctrine-project.org
*
Expand All @@ -32,84 +32,86 @@
*/
class DoctrineCollector extends DataCollector implements Renderable, AssetProvider
{
protected $debugStack;
protected $debugStack;

/**
* DoctrineCollector constructor.
* @param $debugStackOrEntityManager
* @throws DebugBarException
*/
public function __construct($debugStackOrEntityManager)
{
if ($debugStackOrEntityManager instanceof EntityManager) {
$debugStackOrEntityManager = $debugStackOrEntityManager->getConnection()->getConfiguration()->getSQLLogger();
}
if (!($debugStackOrEntityManager instanceof DebugStack)) {
throw new DebugBarException("'DoctrineCollector' requires an 'EntityManager' or 'DebugStack' object");
}
$this->debugStack = $debugStackOrEntityManager;
}
/**
* DoctrineCollector constructor.
*
* @param $debugStackOrEntityManager
*
* @throws DebugBarException
*/
public function __construct($debugStackOrEntityManager)
{
if ($debugStackOrEntityManager instanceof EntityManager) {
$debugStackOrEntityManager = $debugStackOrEntityManager->getConnection()->getConfiguration()->getSQLLogger();
}
if (!($debugStackOrEntityManager instanceof DebugStack)) {
throw new DebugBarException("'DoctrineCollector' requires an 'EntityManager' or 'DebugStack' object");
}
$this->debugStack = $debugStackOrEntityManager;
}

/**
* @return array
*/
public function collect()
{
$queries = array();
$totalExecTime = 0;
foreach ($this->debugStack->queries as $q) {
$queries[] = array(
'sql' => $q['sql'],
'params' => (object) $q['params'],
'duration' => $q['executionMS'],
'duration_str' => $this->formatDuration($q['executionMS'])
);
$totalExecTime += $q['executionMS'];
}
/**
* @return array
*/
public function collect()
{
$queries = [];
$totalExecTime = 0;
foreach ($this->debugStack->queries as $q) {
$queries[] = [
'sql' => $q['sql'],
'params' => (object) $q['params'],
'duration' => $q['executionMS'],
'duration_str' => $this->formatDuration($q['executionMS'])
];
$totalExecTime += $q['executionMS'];
}

return array(
'nb_statements' => count($queries),
'accumulated_duration' => $totalExecTime,
'accumulated_duration_str' => $this->formatDuration($totalExecTime),
'statements' => $queries
);
}
return [
'nb_statements' => count($queries),
'accumulated_duration' => $totalExecTime,
'accumulated_duration_str' => $this->formatDuration($totalExecTime),
'statements' => $queries
];
}

/**
* @return string
*/
public function getName()
{
return 'doctrine';
}
/**
* @return string
*/
public function getName()
{
return 'doctrine';
}

/**
* @return array
*/
public function getWidgets()
{
return array(
"database" => array(
"icon" => "arrow-right",
"widget" => "PhpDebugBar.Widgets.SQLQueriesWidget",
"map" => "doctrine",
"default" => "[]"
),
"database:badge" => array(
"map" => "doctrine.nb_statements",
"default" => 0
)
);
}
/**
* @return array
*/
public function getWidgets()
{
return [
'database' => [
'icon' => 'arrow-right',
'widget' => 'PhpDebugBar.Widgets.SQLQueriesWidget',
'map' => 'doctrine',
'default' => '[]'
],
'database:badge' => [
'map' => 'doctrine.nb_statements',
'default' => 0
]
];
}

/**
* @return array
*/
public function getAssets()
{
return array(
'css' => 'widgets/sqlqueries/widget.css',
'js' => 'widgets/sqlqueries/widget.js'
);
}
/**
* @return array
*/
public function getAssets()
{
return [
'css' => 'widgets/sqlqueries/widget.css',
'js' => 'widgets/sqlqueries/widget.js'
];
}
}
Loading

0 comments on commit adfc6e9

Please sign in to comment.