1212namespace Cache \CacheBundle \DataCollector ;
1313
1414use Cache \CacheBundle \Cache \LoggingCachePool ;
15- use Cache \CacheBundle \Service \CacheService ;
1615use Symfony \Component \HttpFoundation \Request ;
1716use Symfony \Component \HttpFoundation \Response ;
1817use Symfony \Component \HttpKernel \DataCollector \DataCollector ;
1918
2019/**
21- * Class CacheDataCollector
20+ * Class CacheDataCollector.
2221 *
2322 * @author Aaron Scherer <[email protected] > 2423 */
2524class CacheDataCollector extends DataCollector
2625{
2726 /**
28- * Template name
27+ * Template name.
2928 *
3029 * @type string
3130 */
3231 const TEMPLATE = 'CacheBundle:Collector:cache.html.twig ' ;
3332
3433 /**
35- * @var LoggingCachePool[]
34+ * @type LoggingCachePool[]
3635 */
3736 private $ instances = [];
3837
3938 /**
40- * @param $name
41- * @param LoggingCachePool $instance
39+ * @param $name
40+ * @param LoggingCachePool $instance
4241 */
4342 public function addInstance ($ name , LoggingCachePool $ instance )
4443 {
@@ -59,7 +58,7 @@ public function collect(Request $request, Response $response, \Exception $except
5958 $ empty = ['calls ' => [], 'config ' => [], 'options ' => [], 'statistics ' => []];
6059 $ this ->data = ['instances ' => $ empty , 'total ' => $ empty ];
6160 foreach ($ this ->instances as $ name => $ instance ) {
62- $ calls = $ instance ->getCalls ();
61+ $ calls = $ instance ->getCalls ();
6362 $ this ->data ['instances ' ]['calls ' ][$ name ] = $ calls ;
6463 }
6564 $ this ->data ['instances ' ]['statistics ' ] = $ this ->calculateStatistics ();
@@ -79,7 +78,7 @@ public function getName()
7978 }
8079
8180 /**
82- * Method returns amount of logged Cache reads: "get" calls
81+ * Method returns amount of logged Cache reads: "get" calls.
8382 *
8483 * @return array
8584 */
@@ -89,7 +88,7 @@ public function getStatistics()
8988 }
9089
9190 /**
92- * Method returns the statistic totals
91+ * Method returns the statistic totals.
9392 *
9493 * @return array
9594 */
@@ -99,7 +98,7 @@ public function getTotals()
9998 }
10099
101100 /**
102- * Method returns all logged Cache call objects
101+ * Method returns all logged Cache call objects.
103102 *
104103 * @return mixed
105104 */
@@ -122,24 +121,24 @@ private function calculateStatistics()
122121 'hits ' => 0 ,
123122 'misses ' => 0 ,
124123 'writes ' => 0 ,
125- 'deletes ' => 0
124+ 'deletes ' => 0 ,
126125 ];
127126 foreach ($ calls as $ call ) {
128127 $ statistics [$ name ]['calls ' ] += 1 ;
129128 $ statistics [$ name ]['time ' ] += $ call ->time ;
130- if ($ call ->name == 'fetch ' ) {
129+ if ($ call ->name === 'fetch ' ) {
131130 $ statistics [$ name ]['reads ' ] += 1 ;
132131 if ($ call ->result !== false ) {
133132 $ statistics [$ name ]['hits ' ] += 1 ;
134133 } else {
135134 $ statistics [$ name ]['misses ' ] += 1 ;
136135 }
137- } elseif ($ call ->name == 'contains ' && $ call ->result === false ) {
136+ } elseif ($ call ->name === 'contains ' && $ call ->result === false ) {
138137 $ statistics [$ name ]['reads ' ] += 1 ;
139138 $ statistics [$ name ]['misses ' ] += 1 ;
140- } elseif ($ call ->name == 'save ' ) {
139+ } elseif ($ call ->name === 'save ' ) {
141140 $ statistics [$ name ]['writes ' ] += 1 ;
142- } elseif ($ call ->name == 'delete ' ) {
141+ } elseif ($ call ->name === 'delete ' ) {
143142 $ statistics [$ name ]['deletes ' ] += 1 ;
144143 }
145144 }
0 commit comments