Webmozart\Assert\Assert::oneOf PHP Method

oneOf() public static method

public static oneOf ( $value, array $values, $message = '' )
$values array
    public static function oneOf($value, array $values, $message = '')
    {
        if (!in_array($value, $values, true)) {
            static::reportInvalidArgument(sprintf($message ?: 'Expected one of: %2$s. Got: %s', static::valueToString($value), implode(', ', array_map(array('static', 'valueToString'), $values))));
        }
    }

Usage Example

Esempio n. 1
0
 /**
  * {@inheritdoc}
  */
 public function getMessages(ConversationInterface $conversation, $offset = 0, $limit = 20, $sortDirection = 'ASC')
 {
     Assert::integer($offset, '$offset expected an integer in Repository::getMessages(). Got: %s');
     Assert::integer($limit, '$limit expected an integer in Repository::getMessages(). Got: %s');
     Assert::oneOf(strtoupper($sortDirection), ['ASC', 'DESC'], '$sortDirection expected either ASC or DESC in Repository::getMessages(). Got: %s');
     return $this->driver->findMessages($conversation, $offset, $limit, $sortDirection);
 }
All Usage Examples Of Webmozart\Assert\Assert::oneOf