e. * * @return mixed */ protected function maybe_cast_value( string $name, $value ) { if ( isset( self::OPTION_TYPES[ $name ] ) ) { /** @var CastableValueInterface $class */ $class = self::OPTION_TYPES[ $name ]; $value = $class::cast( $value ); } return $value; } /** * Convert to a specific value type. * * @param string $name The option name. * @param mixed $value The option value. * * @return mixed * @throws InvalidValue When the value is invalid. */ protected function maybe_convert_value( string $name, $value ) { if ( isset( self::OPTION_TYPES[ $name ] ) ) { $class = self::OPTION_TYPES[ $name ]; $value = new $class( $value ); } return $value; } /** * Return raw value. * * @param mixed $value Possible object value. * * @return mixed */ protected function raw_value( $value ) { return $value instanceof ValueInterface ? $value->get() : $value; } /** * Prefix an option name with the plugin prefix. * * @param string $name * * @return string */ protected function prefix_name( string $name ): string { return "{$this->get_slug()}_{$name}"; } }