Trait Yiisoft\Validator\Rule\Trait\WhenTrait
An implementation for Yiisoft\Validator\WhenInterface intended to be included in rules. Requires an additional private class
property $when. In package rules it's null by default:
public function __construct(
// ...
private Closure|null $when = null
// ...
) {
}
Public Methods
| Method | Description | Defined By |
|---|---|---|
| getWhen() | A getter for $when property. |
Yiisoft\Validator\Rule\Trait\WhenTrait |
| when() | An immutable setter to change $when property. |
Yiisoft\Validator\Rule\Trait\WhenTrait |
Method Details
A getter for $when property.
| public getWhen( ): Closure|null | ||
| return | Closure|null |
Current value:
|
|---|---|---|
public function getWhen(): ?Closure
{
return $this->when;
}
An immutable setter to change $when property.
| public when( Closure|null $value ): $this | ||
| $value | Closure|null |
A new value:
|
| return | $this |
The new instance with a changed value. |
|---|---|---|
public function when(?Closure $value): static
{
$new = clone $this;
$new->when = $value;
return $new;
}
Signup or Login in order to comment.