Returns whether the given direction is valid.

@param string $direction
@param bool $throw

@return bool
970484
static public function isValid($direction, $throw = false)
    {
        $valid = in_array($direction, [
            static::NONE,
            static::ASC,
            static::DESC,
        ], true);

        if (!$valid && $throw) {
            throw new InvalidArgumentException(sprintf("The direction '%s' is not valid.", $direction));
        }

        return $valid;
    }
1225601
public static function setFetchSortingDirection($direction)
    {
        $direction = strtoupper($direction);

        if ($direction == 'RANDOM') {
            $direction = 'RAND';
        }

        self::$_fetchSortDirection = (in_array($direction, array('RAND', 'ASC', 'DESC')) ? $direction : null);
    }
503339
public function setDirection(int $pin, string $direction, bool $invert = false): bool
    {
        $this->export($pin);
        system("echo {$direction} > /sys/class/gpio/gpio{$pin}/direction");

        if ($invert) {
            $inverted = intval($invert);
            system("echo {$inverted} > /sys/class/gpio/gpio{$pin}/active_low");
        }

        if (file_exists("/sys/class/gpio/gpio{$pin}/direction") && (file_get_contents("/sys/class/gpio/gpio{$pin}/direction") == $direction)) {
            return true;
        }

        return false;

    }
1275580
public function search($condition, $direction = null) {
      $strategy = Search::create();
      if ($direction !== null) {
        $strategy->setDirection($direction);
      }
      $query = $this->buildStrategyCondition($condition, $strategy);
      return $this->process($query);
    }
1234286
public function move($direction)
    {
        if ($direction === self::DIR_FORWARD) {
            return $this->next();
        } elseif ($direction === self::DIR_BACKWARD) {
            return $this->prev();
        }

        throw new InvalidArgumentException(sprintf('Unknown direction %s', $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;
	}
1028920
public function check(array $insert, bool $throw = true): bool
    {
        foreach ($this->schema as $key => $rules) {
            // Check each key by given rules and respond
            // due to required flow.
            $result = $this->processRules($key, explode('|', $rules), $insert);

            if (!$result['status'] && $throw) {
                throw new InvalidArgumentException(
                    sprintf($result['message'], $key)
                );
            }
        }

        return $result['status'] ?? true;
    }
310294
function directionStr(direction) {
    if (direction == DIRECTION_DOWN) {
        return 'down';
    } else if (direction == DIRECTION_UP) {
        return 'up';
    } else if (direction == DIRECTION_LEFT) {
        return 'left';
    } else if (direction == DIRECTION_RIGHT) {
        return 'right';
    }
    return '';
}
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;
    }
1312248
public function order($direction = null)
    {
        if (is_null($direction)) {
            $direction = $this->getOrderDirection();
        } else {
            $this->setOrderDirection($direction);
        }

        // if a direction is set
        if (!empty($direction)) {
            if (!is_string($this->order) && is_callable($this->order)) {
                call_user_func_array($this->order, $this);
            } else {

                $table = $this->getTable();

                // verify that source is a query
                if (!$table->isSourceQueryBuilder()) {
                    throw new \Exception('Table source is not an instance of query builder');
                }

                $table->getSource()->orderBy($this->order, $direction);
            }
        }

        return $this;
    }
856799
public function execute($direction, $replay = false)
    {
        if ('down' === $direction && $replay) {
            throw new AbortException(
                'Cannot run \'down\' and replay it. Use replay with \'up\''
            );
        }

        try {
            $start = microtime(true);

            $this->state = self::STATE_PRE;

            $this->migration->{'pre' . ucfirst($direction)}($this->db);

            if ('up' === $direction) {
                $this->outputWriter->write("\n" . sprintf('  <info>++</info> migrating <comment>%s</comment>', $this->version) . "\n");
            } else {
                $this->outputWriter->write("\n" . sprintf('  <info>--</info> reverting <comment>%s</comment>', $this->version) . "\n");
            }

            $this->state = self::STATE_EXEC;

            $this->migration->$direction($this->db);

            $this->updateStatisticsAfter();

            if ('up' === $direction) {
                $this->markMigrated($replay);
            } else {
                $this->markNotMigrated();
            }

            $this->summarizeStatistics();

            $this->state = self::STATE_POST;
            $this->migration->{'post' . ucfirst($direction)}($this->db);

            $end = microtime(true);
            $this->time = round($end - $start, 2);
            if ('up' === $direction) {
                $this->outputWriter->write(sprintf("\n  <info>++</info> migrated (%ss)", $this->time));
            } else {
                $this->outputWriter->write(sprintf("\n  <info>--</info> reverted (%ss)", $this->time));
            }

            $this->state = self::STATE_NONE;
        } catch (SkipException $e) {
            // now mark it as migrated
            if ('up' === $direction) {
                $this->markMigrated();
            } else {
                $this->markNotMigrated();
            }

            $this->outputWriter->write(sprintf("\n  <info>SS</info> skipped (Reason: %s)", $e->getMessage()));

            $this->state = self::STATE_NONE;
        } catch (\Exception $e) {
            $this->outputWriter->write(sprintf(
                '<error>Migration %s failed during %s. Error %s</error>',
                $this->version, $this->getExecutionState(), $e->getMessage()
            ));

            $this->state = self::STATE_NONE;
            throw $e;
        }
    }
739035
public function orderBy( $expression, $direction = 'ASC' ) {
		$direction = strtoupper( $direction );
		if ( !in_array( $direction, array( 'ASC', 'DESC' ) ) ) {
			throw new InvalidArgumentException( '$direction has to be either ASC or DESC' );
		}

		$this->expressionValidator->validate( $expression,
			ExpressionValidator::VALIDATE_VARIABLE | ExpressionValidator::VALIDATE_FUNCTION
		);

		$this->usageValidator->trackUsedPrefixes( $expression );
		$this->usageValidator->trackUsedVariables( $expression );
		$this->modifiers['ORDER BY'] = $direction . ' (' . $expression . ')';
	}
567617
public function postFlightCheck($direction = null)
    {
        foreach ($this->tables as $table) {
            if ($table->hasPendingActions()) {
                throw new \RuntimeException('Migration has pending actions after execution!');
            }
        }
    }
780970
public function canSendHeaders($throw = false)
        {
            $ok = headers_sent($file, $line);

            if ($ok && $throw && $this->headersSentThrowsException) {
                throw new Exception('Cannot send headers; headers already sent in ' . $file . ', line ' . $line);
            }

            return !$ok;
        }
39355
function direction(value) {
    var raw = this.unwrapRaw(value);
    if (raw) {
      return raw;
    }
    return orderBys.indexOf((value || '').toLowerCase()) !== -1 ? value : 'asc';
  }
919506
public static function lastChangeComparator(int $direction = 1): Closure
    {
        return static function (GedcomRecord $x, GedcomRecord $y) use ($direction): int {
            return $direction * ($x->lastChangeTimestamp() <=> $y->lastChangeTimestamp());
        };
    }
592623
public function get($direction = 'regular')
    {
        if ($this->count() == 0) {
            return $this->default;
        }

        if ($direction === 'downward') {
            $this->collection = array_reverse($this->collection);
        }

        $this->addPageName();

        if ($direction === 'reverse') {
            $this->collection = array_reverse($this->collection);
        }

        return implode($this->getDelimeter(), $this->collection);
    }