northrook/types

Self-validating data types for PHP

dev-main 2024-06-12 07:49 UTC

This package is auto-updated.

Last update: 2024-11-12 08:37:35 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;
	}

}