本文整理匯總了PHP中Result::isValid方法的典型用法代碼示例。如果您正苦於以下問題:PHP Result::isValid方法的具體用法?PHP Result::isValid怎麽用?PHP Result::isValid使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Result
的用法示例。
在下文中一共展示了Result::isValid方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: testSetIsValid
/**
* @covers W3C\Validation\Result::setIsValid
* @covers W3C\Validation\Result::isValid
*/
public function testSetIsValid()
{
$this->result->setIsValid(false);
$this->assertFalse($this->result->isValid());
$this->result->setIsValid(true);
$this->assertTrue($this->result->isValid());
}
示例2: the_result_correctly_reports_whether_or_not_it_is_valid
/**
* @group response-validation
* @test
*/
public function the_result_correctly_reports_whether_or_not_it_is_valid()
{
$result = new Result();
$this->assertTrue($result->isValid());
$this->assertCount(0, $result->getErrors());
$result->addError('Oh noooos!');
$this->assertFalse($result->isValid());
$this->assertCount(1, $result->getErrors());
}
示例3: merge
/**
* Returns a result that represents the combination of the two given results.
* In particular, this means:
*
* If $a->getErrors() is empty and $a->isValid() is true, $b is returned.
* If $b->getErrors() is empty and $b->isValid() is true, $a is returned.
*
* Otherwise, a new Result is constructed that contains
* all errors from $a and $b, and is considered valid
* if both $a and $b were valid.
*
* @since 0.1
*
* @param Result $a
* @param Result $b
*
* @return Result
*/
public static function merge(Result $a, Result $b)
{
$aErrors = $a->getErrors();
$bErrors = $b->getErrors();
if ($a->isValid() && empty($aErrors)) {
return $b;
} elseif ($b->isValid() && empty($bErrors)) {
return $a;
} else {
$errors = array_merge($aErrors, $bErrors);
$valid = $a->isValid() && $b->isValid();
return new Result($valid, $errors);
}
}
示例4: mergeWithResult
/**
* @param Result $result
* @return $this
*/
public function mergeWithResult(Result $result)
{
if ($this->_isValid && !$result->isValid()) {
$this->_isValid = false;
}
$this->_errorMessages = array_merge($this->_errorMessages, $result->getErrorMessages());
return $this;
}