<commit_before><?php

declare(strict_types=1);

namespace Overblog\GraphQLBundle\DataCollector;

use GraphQL\Error\SyntaxError;
use GraphQL\Language\AST\DocumentNode;
use GraphQL\Language\AST\FieldNode;
use GraphQL\Language\AST\OperationDefinitionNode;
use GraphQL\Language\Parser;
use Overblog\GraphQLBundle\Event\ExecutorResultEvent;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\DataCollector\DataCollector;
use Throwable;
use function count;
use function microtime;

class GraphQLCollector extends DataCollector
{
    /**
     * GraphQL Batchs executed.
     */
    protected array $batches = [];

    public function collect(Request $request, Response $response, Throwable $exception = null): void
    {
        $error = false;
        $count = 0;
        $schema = null;
        foreach ($this->batches as $batch) {
            if (!$schema) {
                $schema = $batch['schema'];
            }
            if (isset($batch['error'])) {
                $error = true;
            }
            $count += $batch['count'];
        }

        $this->data = [
            'schema' => $schema,
            'batches' => $this->batches,
            'count' => $count,
            'error' => $error,
        ];
    }

    /**
     * Check if we have an error.
     */
    public function getError(): bool
    {
        return $this->data['error'] ?? false;
    }

    /**
     * Count the number of executed queries.
     */
    public function getCount(): int
    {
        return $this->data['count'] ?? 0;
    }

    /**
     * Return the targeted schema.
     *
     * @return string|false
     */
    public function getSchema(): ?string
    {
        return $this->data['schema'];
    }

    /**
     * Return the list of executed batch.
     */
    public function getBatches(): array
    {
        return $this->data['batches'] ?? [];
    }<commit_msg>Remove useless docblock<commit_after><?php

declare(strict_types=1);

namespace Overblog\GraphQLBundle\DataCollector;

use GraphQL\Error\SyntaxError;
use GraphQL\Language\AST\DocumentNode;
use GraphQL\Language\AST\FieldNode;
use GraphQL\Language\AST\OperationDefinitionNode;
use GraphQL\Language\Parser;
use Overblog\GraphQLBundle\Event\ExecutorResultEvent;
use Symfony\Component\HttpFoundation\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\DataCollector\DataCollector;
use Throwable;
use function count;
use function microtime;

class GraphQLCollector extends DataCollector
{
    /**
     * GraphQL Batchs executed.
     */
    protected array $batches = [];

    public function collect(Request $request, Response $response, Throwable $exception = null): void
    {
        $error = false;
        $count = 0;
        $schema = null;
        foreach ($this->batches as $batch) {
            if (!$schema) {
                $schema = $batch['schema'];
            }
            if (isset($batch['error'])) {
                $error = true;
            }
            $count += $batch['count'];
        }

        $this->data = [
            'schema' => $schema,
            'batches' => $this->batches,
            'count' => $count,
            'error' => $error,
        ];
    }

    /**
     * Check if we have an error.
     */
    public function getError(): bool
    {
        return $this->data['error'] ?? false;
    }

    /**
     * Count the number of executed queries.
     */
    public function getCount(): int
    {
        return $this->data['count'] ?? 0;
    }

    /**
     * Return the targeted schema.
     */
    public function getSchema(): ?string
    {
        return $this->data['schema'];
    }

    /**
     * Return the list of executed batch.
     */
    public function getBatches(): array
    {
        return $this->data['batches'] ?? [];
    }
{'fraction_non_alphanumeric': 0.13040103492884864, 'fraction_numerical': 0.0015523932729624838, 'mean_word_length': 2.1766639276910436, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 25, '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': '352793', 'n_tokens_mistral': 1113, 'n_tokens_neox': 1093, 'n_words': 258}