northrook/types

Self-validating data types for PHP

dev-main 2024-03-29 07:26 UTC

This package is auto-updated.

Last update: 2024-04-29 07:41:16 UTC


README

Updating the value

Create public function update(), with the argument $value, typed to match.

This method may be used to handle additional logic, as long as it results in a valid $value.

Assign the updated value using $this->updateValue( $value ).

The updateValue method revalidates the new value, unless revalidate: false is passed.

The method must return self.

// Example:
class CustomType extends Type {

	public function update( ?string $value ): self {
		$this->updateValue( $value );

		return $this;
	}

}