<commit_before><?php

declare(strict_types=1);

namespace Doctrine\ODM\MongoDB\Aggregation;

use Doctrine\ODM\MongoDB\Iterator\Iterator;
use GeoJson\Geometry\Point;

/**
 * Fluent interface for building aggregation pipelines.
 *
 * @internal
 */
abstract class Stage
{
    /** @var Builder */
    protected $builder;

    public function __construct(Builder $builder)
    {
        $this->builder = $builder;
    }

    /**
     * Assembles the aggregation stage
     */
    abstract public function getExpression() : array;

    /**
     * Executes the aggregation pipeline
     */
    public function execute(array $options = []) : Iterator
    {
        return $this->builder->execute($options);
    }

    /**
     * Categorizes incoming documents into groups, called buckets, based on a
     * specified expression and bucket boundaries.
     *
     * Each bucket is represented as a document in the output. The document for
     * each bucket contains an _id field, whose value specifies the inclusive
     * lower bound of the bucket and a count field that contains the number of
     * documents in the bucket. The count field is included by default when the
     * output is not specified.
     *
     * @see https://docs.mongodb.com/manual/reference/operator/aggregation/bucket/
     */
    public function bucket() : Stage\Bucket
    {
        return $this->builder->bucket();
    }

    /**<commit_msg>Add missing `addFields` method for Stage abstract<commit_after><?php

declare(strict_types=1);

namespace Doctrine\ODM\MongoDB\Aggregation;

use Doctrine\ODM\MongoDB\Iterator\Iterator;
use GeoJson\Geometry\Point;

/**
 * Fluent interface for building aggregation pipelines.
 *
 * @internal
 */
abstract class Stage
{
    /** @var Builder */
    protected $builder;

    public function __construct(Builder $builder)
    {
        $this->builder = $builder;
    }

    /**
     * Assembles the aggregation stage
     */
    abstract public function getExpression() : array;

    /**
     * Executes the aggregation pipeline
     */
    public function execute(array $options = []) : Iterator
    {
        return $this->builder->execute($options);
    }

    /**
     * Adds new fields to documents. $addFields outputs documents that contain
     * all existing fields from the input documents and newly added fields.
     *
     * The $addFields stage is equivalent to a $project stage that explicitly
     * specifies all existing fields in the input documents and adds the new
     * fields.
     *
     * @see https://docs.mongodb.com/manual/reference/operator/aggregation/addFields/
     */
    public function addFields() : Stage\AddFields
    {
        return $this->builder->addFields();
    }

    /**
     * Categorizes incoming documents into groups, called buckets, based on a
     * specified expression and bucket boundaries.
     *
     * Each bucket is represented as a document in the output. The document for
     * each bucket contains an _id field, whose value specifies the inclusive
     * lower bound of the bucket and a count field that contains the number of
     * documents in the bucket. The count field is included by default when the
     * output is not specified.
     *
     * @see https://docs.mongodb.com/manual/reference/operator/aggregation/bucket/
     */
    public function bucket() : Stage\Bucket
    {
        return $this->builder->bucket();
    }

    /**
{'fraction_non_alphanumeric': 0.09349355216881594, 'fraction_numerical': 0.0005861664712778429, 'mean_word_length': 2.697724810400867, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, 'https://': 3, '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': '7240908', 'n_tokens_mistral': 916, 'n_tokens_neox': 883, 'n_words': 311}