<commit_before><?php

namespace Mdd\QueryBuilder\Queries\Parts;

use Mdd\QueryBuilder\PartBuilder;

class OrderBy implements PartBuilder
{
    const
        ASC = 'ASC',
        DESC = 'DESC';

    private
        $orders;

    public function __construct()
    {
        $this->orders = array();
    }

    public function orderBy($column, $direction = self::ASC)
    {
        $directrion = $this->validateDirection((string) $direction);

        $this->orders[$column] = $direction;
    }

    public function toString()
    {
        $orders = array();
        foreach($this->orders as $column => $direction)
        {
            if(! empty($column))
            {
                $orders[] = $column . ' ' . $direction;
            }
        }

        if(empty($orders))
        {
            return '';
        }

        return sprintf('ORDER BY %s', implode(', ', $orders));
    }

    private function validateDirection($direction)
    {
        $availableDirections = array(self::ASC, self::DESC);
        if(! in_array($direction, $availableDirections))
        {
            throw new \InvalidArgumentException(sprintf('Unsupported ORDER BY direction "%s"', $direction));
        }

        $this->direction = $direction;
    }
}<commit_msg>Remove useless class attribute<commit_after><?php

namespace Mdd\QueryBuilder\Queries\Parts;

use Mdd\QueryBuilder\PartBuilder;

class OrderBy implements PartBuilder
{
    const
        ASC = 'ASC',
        DESC = 'DESC';

    private
        $orders;

    public function __construct()
    {
        $this->orders = array();
    }

    public function orderBy($column, $direction = self::ASC)
    {
        $this->validateDirection($direction);

        $this->orders[$column] = (string) $direction;
    }

    public function toString()
    {
        $orders = array();
        foreach($this->orders as $column => $direction)
        {
            if(! empty($column))
            {
                $orders[] = $column . ' ' . $direction;
            }
        }

        if(empty($orders))
        {
            return '';
        }

        return sprintf('ORDER BY %s', implode(', ', $orders));
    }

    private function validateDirection($direction)
    {
        $availableDirections = array(self::ASC, self::DESC);
        if(! in_array($direction, $availableDirections))
        {
            throw new \InvalidArgumentException(sprintf('Unsupported ORDER BY direction "%s"', $direction));
        }
    }
}
{'fraction_non_alphanumeric': 0.13586736756975334, 'fraction_numerical': 0.0, 'mean_word_length': 2.0207570207570207, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 14, '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': '2336420', 'n_tokens_mistral': 692, 'n_tokens_neox': 669, 'n_words': 144}