public function getDirectionAsString(
        $direction_id = null,
        $include_nulls_ordering = true
    ) {
        if ($direction_id === null) {
            $direction_id = $this->direction;
        }

        switch ($direction_id) {
            case self::ORDER_BY_DIR_NONE:
                $direction = '';
                break;

            case self::ORDER_BY_DIR_ASCENDING:
                $direction = 'asc';
                break;

            case self::ORDER_BY_DIR_DESCENDING:
                $direction = 'desc';
                break;

            default:
                throw new SwatException(
                    sprintf("Ordering direction '%s' not found.", $direction_id)
                );
        }

        if ($include_nulls_ordering && $this->nulls_ordering !== null) {
            switch ($this->nulls_ordering) {
                case self::NULLS_FIRST:
                    $direction .= ' nulls first';
                    break;

                case self::NULLS_LAST:
                    $direction .= ' nulls last';
                    break;

                default:
                    throw new SwatException(
                        sprintf(
                            "Nulls ordering '%s' not found.",
                            $this->nulls_ordering
                        )
                    );
            }
        }

        return $direction;
    }