<commit_before><?php

namespace Rb\Specification\Doctrine\Query;

use Doctrine\ORM\QueryBuilder;
use Rb\Specification\Doctrine\AbstractSpecification;
use Rb\Specification\Doctrine\Exception\InvalidArgumentException;
use Rb\Specification\Doctrine\SpecificationInterface;

/**
 * Class Join.
 */
class Join extends AbstractSpecification
{
    const JOIN       = 'join';
    const LEFT_JOIN  = 'leftJoin';
    const INNER_JOIN = 'innerJoin';

    protected static $types = [self::JOIN, self::LEFT_JOIN, self::INNER_JOIN];

    /**
     * @var string
     */
    private $newAlias;

    /**
     * @var string|null
     */
    private $conditionType = null;

    /**
     * @var string|SpecificationInterface|null
     */
    private $condition = null;

    /**
     * @var string|null
     */
    private $indexedBy = null;

    /**
     * @var string
     */
    private $type = self::JOIN;

    /**
     * @param string      $field
     * @param string      $newAlias
     * @param string|null $dqlAlias
     *
     * @throws InvalidArgumentException
     */
    public function __construct($field, $newAlias, $dqlAlias = null)
    {
        $this->newAlias = $newAlias;

        parent::__construct($field, $dqlAlias);
    }

    /**
     * @param string $type
     *
     * @throws InvalidArgumentException
     */
    public function setType($type)
    {
        if (! in_array($type, self::$types, true)) {
            throw new InvalidArgumentException(sprintf(
                '"%s" is not a valid type! Valid types: %s',
                $type,
                implode(', ', self::$types)
            ));
        }

        $this->type = $type;
    }

    /**
     * {@inheritdoc}<commit_msg>Have setType() return $this to realize fluent setter<commit_after><?php

namespace Rb\Specification\Doctrine\Query;

use Doctrine\ORM\QueryBuilder;
use Rb\Specification\Doctrine\AbstractSpecification;
use Rb\Specification\Doctrine\Exception\InvalidArgumentException;
use Rb\Specification\Doctrine\SpecificationInterface;

/**
 * Class Join.
 */
class Join extends AbstractSpecification
{
    const JOIN       = 'join';
    const LEFT_JOIN  = 'leftJoin';
    const INNER_JOIN = 'innerJoin';

    protected static $types = [self::JOIN, self::LEFT_JOIN, self::INNER_JOIN];

    /**
     * @var string
     */
    private $newAlias;

    /**
     * @var string|null
     */
    private $conditionType = null;

    /**
     * @var string|SpecificationInterface|null
     */
    private $condition = null;

    /**
     * @var string|null
     */
    private $indexedBy = null;

    /**
     * @var string
     */
    private $type = self::JOIN;

    /**
     * @param string      $field
     * @param string      $newAlias
     * @param string|null $dqlAlias
     *
     * @throws InvalidArgumentException
     */
    public function __construct($field, $newAlias, $dqlAlias = null)
    {
        $this->newAlias = $newAlias;

        parent::__construct($field, $dqlAlias);
    }

    /**
     * @param string $type
     *
     * @return $this
     *
     * @throws InvalidArgumentException
     */
    public function setType($type)
    {
        if (! in_array($type, self::$types, true)) {
            throw new InvalidArgumentException(sprintf(
                '"%s" is not a valid type! Valid types: %s',
                $type,
                implode(', ', self::$types)
            ));
        }

        $this->type = $type;
        
        return $this;
    }

    /**
     * {@inheritdoc}
{'fraction_non_alphanumeric': 0.12972508591065293, 'fraction_numerical': 0.0, 'mean_word_length': 2.138364779874214, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '5587303', 'n_tokens_mistral': 1073, 'n_tokens_neox': 1039, 'n_words': 224}