src/Charcoal/Source/Order.php
public function setMode($mode)
    {
        if ($mode === null) {
            $this->mode = $mode;
            return $this;
        }

        if (!is_string($mode)) {
            throw new InvalidArgumentException(
                'Order Mode must be a string.'
            );
        }

        $mode  = strtolower($mode);
        $valid = $this->validModes();
        if (!in_array($mode, $valid)) {
            throw new InvalidArgumentException(sprintf(
                'Invalid Order Mode. Must be one of "%s"',
                implode('", "', $valid)
            ));
        }

        if (in_array($mode, [ self::MODE_ASC, self::MODE_DESC ])) {
            $this->setDirection($mode);
        }

        $this->mode = $mode;
        return $this;
    }
public function setMode($mode)
    {
        if ($mode === null) {
            $this->mode = $mode;
            return $this;
        }

        if (!is_string($mode)) {
            throw new InvalidArgumentException(
                'Order Mode must be a string.'
            );
        }

        $mode  = strtolower($mode);
        $valid = $this->validModes();
        if (!in_array($mode, $valid)) {
            throw new InvalidArgumentException(sprintf(
                'Invalid Order Mode. Must be one of "%s"',
                implode('", "', $valid)
            ));
        }

        if (in_array($mode, [ self::MODE_ASC, self::MODE_DESC ])) {
            $this->setDirection($mode);
        }

        $this->mode = $mode;
        return $this;
    }
public function setMode ( $ mode ) { if ( $ mode === null ) { $ this -> mode = $ mode ; return $ this ; } if ( ! is_string ( $ mode ) ) { throw new InvalidArgumentException ( 'Order Mode must be a string.' ) ; } $ mode = strtolower ( $ mode ) ; $ valid = $ this -> validModes ( ) ; if ( ! in_array ( $ mode , $ valid ) ) { throw new InvalidArgumentException ( sprintf ( 'Invalid Order Mode. Must be one of "%s"' , implode ( '", "' , $ valid ) ) ) ; } if ( in_array ( $ mode , [ self :: MODE_ASC , self :: MODE_DESC ] ) ) { $ this -> setDirection ( $ mode ) ; } $ this -> mode = $ mode ; return $ this ; }
Set the, pre-defined, sorting mode.

@param  string|null $mode The sorting mode.
@throws InvalidArgumentException If the mode is not a string or invalid.
@return self
Set the pre - defined sorting mode .