Set the newly selected option based on the direction

@param string $direction 'previous' or 'next'
185289
public function setCurrent($direction)
    {
        list($option, $key) = $this->getCurrent();

        $option->setCurrent(false);

        $new_key = $this->getCurrentKey($direction, $option, $key);

        $this->checkboxes[$new_key]->setCurrent();
    }
204709
public function scroll($direction = 'right')
    {
        $this->setupKeyframes();

        $mapping = $this->getScrollDirectionMapping();

        if (!array_key_exists($direction, $mapping)) {
            return false;
        }

        $lines       = $this->getLines();
        $enter_from  = $mapping[$direction];
        $exit_to     = $mapping[$enter_from];

        $this->animate($this->keyframes->scroll($lines, $enter_from, $exit_to));
    }
1254272
public function move($id, $direction)
    {
        $this->loadModel('Locale.Languages');
        $language = $this->Languages->get($id);
        $unordered = $this->Languages->find()
            ->select(['id', 'ordering'])
            ->order(['ordering' => 'ASC'])
            ->all()
            ->extract('id')
            ->toArray();

        $position = array_search($language->id, $unordered);
        if (!is_integer($position)) {
            $this->redirect($this->referer());
        }

        $direction = $direction === 'up' ? 'down' : 'up'; // fix orientation, top-down to left-right
        $ordered = array_move($unordered, $position, $direction);
        if (md5(serialize($ordered)) != md5(serialize($unordered))) {
            foreach ($ordered as $ordering => $id) {
                $this->Languages->updateAll(compact('ordering'), compact('id'));
            }
        }

        $this->title(__d('locale', 'Reorder Language'));
        $this->Flash->success(__d('locale', 'Language successfully reordered!'));
        $this->redirect($this->referer());
    }
1058419
protected function setOption($opt)
    {
        if ($this->checkDiscription($opt)) {
            $this->advanceOpt($opt);
        } else {
            $this->simpleOpt($opt);
        }
    }
106026
public function setOptions($options) 
	{
		foreach ($this->options as $key => $option) {
			if (isset($options[$key])) {
				$this->options[$key] = $options[$key];
			}
		}
	}
973417
public static function validate(string $direction)
    {
        if (!isset(self::$directions[$direction])) {
            throw InvalidArgumentException::format(
                    'Invalid ordering direction: expecting one of (%s), \'%s\' given',
                    Debug::formatValues(array_keys(self::$directions)), $direction
            );
        }
    }
1171992
public function sort($field, $direction = self::SORT_DESC) {
		if(empty($this->data['sorts'])) {
			$this->data['sorts'] = array();
		}
		$this->data['sorts'][] = array(
			'field' => $field,
			'direction' => $direction
		);
		return $this;
	}
567617
public function postFlightCheck($direction = null)
    {
        foreach ($this->tables as $table) {
            if ($table->hasPendingActions()) {
                throw new \RuntimeException('Migration has pending actions after execution!');
            }
        }
    }
1155546
public function setOption($option = [])
    {
        if (!isset($option['sandbox'])) {
            $option['sandbox'] = false;
        }
        $this->provider->setOption($option);
    }
300358
public function SetOptions( $options ){
		foreach($options as $option => $value){
			$this->SetOption($option,$value);
		}
	}
8414
public function sortBy(string $field, string $direction = 'asc'): self
    {
        $this->sortBy = [$field, $direction];

        return $this;
    }
973724
final public function setListOrderBy($fields, $direction = "ASC")
    {

        $direction = (in_array(strtoupper(trim($direction)), array('ASC', 'DESC'), TRUE)) ? ' ' . $direction : ' ASC';
        $orderby = NULL;
        //Clean up the order by field list
        if (!empty($fields) && !is_array($fields)) {
            $temp = array();
            foreach (explode(',', $fields) as $part) {
                $part = trim($part);
                $temp[] = $part;
            }

            $orderby = implode(', ', $temp);
        } else if (is_array($fields)) {
            $temp = array();
            foreach ($fields as $field) {
                $part = trim($field);
                $temp[] = $part;
            }
            $orderby = implode(', ', $temp);
        }


        if (!empty($orderby)) {
            $this->listOrderByStatement = "\nORDER BY " . $orderby . $direction;
        }
        //Return this object
        return $this;
    }
583353
public function setDirection($direction)
    {
        if (!in_array($direction, self::$supportedFlipDirection)) {
            throw new \InvalidArgumentException(sprintf(
                    '"%s" Is Not Valid Flip Direction', (string) $direction
            ));
        }
        $this->flipDirection = $direction;

        return $this;
    }
265540
public function setOrderDirection($direction)
    {

        $direction = strtolower($direction);

        if (!in_array($direction, ['asc', 'desc'])) {
            throw new \InvalidArgumentException('$direction must be "asc" or "desc"');
        }

        $this->orderDirection = $direction;
        return $this;
    }
4390
public function setOrientation($orientation)
    {
        if (in_array($orientation, Orientation::asArray(), true) === true) {
            $this->orientation = $orientation;
        } else {
            $msg = "The 'orientation' argument must be a value from the Orientation enumeration.";
            throw new InvalidArgumentException($msg);
        }
    }
343799
public function sortBy($field, $direction = 'desc')
    {
        $this->sortByField = $field;

        if (strtolower($direction) === 'asc') {
            $this->sortByDirection = SORT_ASC;
        } else {
            $this->sortByDirection = SORT_DESC;
        }

        return $this;
    }
1290668
public function setSelected($number)
    {

        for ($i = 1; $i <= count($this->list); $i++) {
            $this->list[$i]['selected'] = false;
        }
        if (isset($this->list[$number])) {
            $this->list[$number]['selected'] = true;
        }
    }