validate_value( $value ); $this->value = $value; } /** * Validate the that value we received is one of the valid types. * * @param string $value * * @throws InvalidType When the value is not valid. */ protected function validate_value( string $value ) { if ( ! array_key_exists( $value, $this->valid_values ) ) { throw InvalidType::from_type( $value, array_keys( $this->valid_values ) ); } } }