/home/kueuepay/public_html/vendor/barryvdh/laravel-debugbar/src/DataCollector/JobsCollector.php
<?php

namespace Barryvdh\Debugbar\DataCollector;

use DebugBar\DataCollector\DataCollector;
use DebugBar\DataCollector\DataCollectorInterface;
use DebugBar\DataCollector\Renderable;
use Illuminate\Contracts\Events\Dispatcher;

/**
 * @deprecated in favor of \DebugBar\DataCollector\ObjectCountCollector
 */
class JobsCollector extends DataCollector implements DataCollectorInterface, Renderable
{
    public $jobs = [];
    public $count = 0;

    /**
     * @param Dispatcher $events
     */
    public function __construct(Dispatcher $events)
    {
        $events->listen(\Illuminate\Queue\Events\JobQueued::class, function ($event) {
            $class = get_class($event->job);
            $this->jobs[$class] = ($this->jobs[$class] ?? 0) + 1;
            $this->count++;
        });
    }

    public function collect()
    {
        ksort($this->jobs, SORT_NUMERIC);

        return ['data' => array_reverse($this->jobs), 'count' => $this->count];
    }

    /**
     * {@inheritDoc}
     */
    public function getName()
    {
        return 'jobs';
    }

    /**
     * {@inheritDoc}
     */
    public function getWidgets()
    {
        return [
            "jobs" => [
                "icon" => "briefcase",
                "widget" => "PhpDebugBar.Widgets.HtmlVariableListWidget",
                "map" => "jobs.data",
                "default" => "{}"
            ],
            'jobs:badge' => [
                'map' => 'jobs.count',
                'default' => 0
            ]
        ];
    }
}
Best Practice

Best Practices

To ensure a smooth integration process and optimal performance, follow these best practices:

  1. Use secure HTTPS connections for all API requests.
  2. Implement robust error handling to handle potential issues gracefully.
  3. Regularly update your integration to stay current with any API changes or enhancements.