The Rise of Contactless Payments:...
In recent years, contactless payments have surged in popularity, driven...
<?php
namespace DebugBar\DataCollector;
use DebugBar\DataCollector\DataCollector;
use DebugBar\DataCollector\DataCollectorInterface;
use DebugBar\DataCollector\Renderable;
/**
* Collector for hit counts.
*/
class ObjectCountCollector extends DataCollector implements DataCollectorInterface, Renderable
{
/** @var string */
private $name;
/** @var string */
private $icon;
/** @var int */
protected $classCount = 0;
/** @var array */
protected $classList = [];
/**
* @param string $name
* @param string $icon
*/
public function __construct($name = 'counter', $icon = 'cubes')
{
$this->name = $name;
$this->icon = $icon;
}
/**
* @param string|mixed $class
* @param int $count
*/
public function countClass($class, $count = 1) {
if (! is_string($class)) {
$class = get_class($class);
}
$this->classList[$class] = ($this->classList[$class] ?? 0) + $count;
$this->classCount += $count;
}
/**
* {@inheritDoc}
*/
public function collect()
{
arsort($this->classList, SORT_NUMERIC);
if (! $this->getXdebugLinkTemplate()) {
return ['data' => $this->classList, 'count' => $this->classCount, 'is_counter' => true];
}
$data = [];
foreach ($this->classList as $class => $count) {
$reflector = class_exists($class) ? new \ReflectionClass($class) : null;
if ($reflector && $link = $this->getXdebugLink($reflector->getFileName())) {
$data[$class] = [
'value' => $count,
'xdebug_link' => $link,
];
} else {
$data[$class] = $count;
}
}
return ['data' => $data, 'count' => $this->classCount, 'is_counter' => true];
}
/**
* {@inheritDoc}
*/
public function getName()
{
return $this->name;
}
/**
* {@inheritDoc}
*/
public function getWidgets()
{
$name = $this->getName();
return [
"$name" => [
'icon' => $this->icon,
'widget' => 'PhpDebugBar.Widgets.HtmlVariableListWidget',
'map' => "$name.data",
'default' => '{}'
],
"$name:badge" => [
'map' => "$name.count",
'default' => 0
]
];
}
}
Blog Section
Dive into our blog to explore the cutting-edge trends in digital payments and NFC technology. Stay updated on the innovations that are revolutionizing transactions, boosting security, and making payments quicker and more convenient. Learn how these advancements are shaping the future of financial interactions and driving the global transition towards a cashless world.
In recent years, contactless payments have surged in popularity, driven...
As digital transactions proliferate, ensuring robust payment security is more critical than ever. Two foundational...
Digital wallets have fundamentally transformed how we manage money, offering a streamlined, secure, and highly...