<commit_before><?php

namespace Barryvdh\Debugbar\DataCollector;

use DebugBar\DataCollector\MessagesCollector;
use Illuminate\Contracts\Auth\Access\Gate;
use Illuminate\Contracts\Auth\Authenticatable;

/**
 * Collector for Laravel's Auth provider
 */
class GateCollector extends MessagesCollector
{
    /**
     * @param Gate $gate
     */
    public function __construct(Gate $gate)
    {
        parent::__construct('gate');

        if (method_exists($gate, 'after')) {
            $gate->after([$this, 'addCheck']);
        }
    }

    public function addCheck(Authenticatable $user, $ability, $result, $arguments = [])
    {
        $label = $result ? 'success' : 'error';

        $this->addMessage([
            'ability' => $ability,
            'result' => $result,
            'user' => $user->getAuthIdentifier(),
            'arguments' => $arguments,
        ], $label, false);
    }
}
<commit_msg>Export gate arguments to save time<commit_after><?php

namespace Barryvdh\Debugbar\DataCollector;

use DebugBar\DataCollector\MessagesCollector;
use Illuminate\Contracts\Auth\Access\Gate;
use Illuminate\Contracts\Auth\Authenticatable;
use Symfony\Component\HttpKernel\DataCollector\Util\ValueExporter;

/**
 * Collector for Laravel's Auth provider
 */
class GateCollector extends MessagesCollector
{
    /** @var ValueExporter */
    protected $exporter;
    /**
     * @param Gate $gate
     */
    public function __construct(Gate $gate)
    {
        parent::__construct('gate');
        $this->exporter = new ValueExporter();

        if (method_exists($gate, 'after')) {
            $gate->after([$this, 'addCheck']);
        }
    }

    public function addCheck(Authenticatable $user, $ability, $result, $arguments = [])
    {
        $label = $result ? 'success' : 'error';

        $this->addMessage([
            'ability' => $ability,
            'result' => $result,
            'user' => $user->getAuthIdentifier(),
            'arguments' => $this->exporter->exportValue($arguments),
        ], $label, false);
    }
}

{'fraction_non_alphanumeric': 0.14467253176930597, 'fraction_numerical': 0.0, 'mean_word_length': 2.7767527675276753, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 20, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2538176', 'n_tokens_mistral': 601, 'n_tokens_neox': 604, 'n_words': 120}