private function guardOptions($options, $constraints) { Assertion::allInArray(array_keys($options), array_keys($constraints)); foreach ($options as $key => $value) { $constraint = $constraints[$key]; if (is_callable($constraint)) { call_user_func($constraint, $value); } } }
private function validate() { Assertion::nullOrString($this->logMessageRegExp); Assertion::nullOrString($this->logMessageInString); Assertion::nullOrString($this->logContextFuzzy); Assertion::nullOrIsInstanceOf($this->logTimeLowerBounds, DateTimeInterface::class); Assertion::nullOrIsInstanceOf($this->logTimeUpperBounds, DateTimeInterface::class); Assertion::nullOrIsArray($this->logLevelList); if (!is_null($this->logLevelList)) { Assertion::notEmpty($this->logLevelList); Assertion::allInArray($this->logLevelList, array_values((new ReflectionClass(LogLevel::class))->getConstants())); } if (!is_null($this->logMessageRegExp)) { Assertion::true(RegexGuardFactory::getGuard()->isRegexValid($this->logMessageRegExp)); } if (!is_null($this->logTimeLowerBounds) && !is_null($this->logTimeUpperBounds)) { Assertion::false($this->logTimeLowerBounds->diff($this->logTimeUpperBounds)->invert); } }
/** * @Then I should see the following names: * * @param TableNode $table */ public function validateNames(TableNode $table) { $list = array_column($table->getHash(), 'username'); Assertion::allInArray($this->filterResult, $list); Assertion::count($this->filterResult, count($list)); }