Automattic\WooCommerce\EmailEditor\Integrations\Core\Renderer\Blocks
Image::reduce_radius_by_border_width
Reduce a single border radius value by the border width, clamped to 0.
Only px (or unitless) values can be combined with the px border width; other units are returned unchanged.
Method of the class: Image{}
No Hooks.
Returns
null. Nothing (null).
Usage
// private - for code of main (parent) class only $result = $this->reduce_radius_by_border_width( $radius, $border_width ): string;
- $radius(mixed) (required)
- Border radius value (e.g. "20px"). Non-scalar values are treated as 0.
- $border_width(float) (required)
- Border width in px.
Image::reduce_radius_by_border_width() Image::reduce radius by border width code WC 11.1.2
private function reduce_radius_by_border_width( $radius, float $border_width ): string {
$radius = is_scalar( $radius ) ? trim( (string) $radius ) : '';
// Non-px units can't be combined with a px border width, so keep them unchanged.
if ( '' !== $radius && ! str_ends_with( $radius, 'px' ) && ! is_numeric( $radius ) ) {
return $radius;
}
$inner = max( 0.0, Styles_Helper::parse_value( $radius ) - $border_width );
return $inner . 'px';
}