# elementor/trunk/modules/atomic-widgets/css-converter/converters/number-property-converter.php

Elementor Website Builder – more than just a page builder, version trunk. 41 lines.

- Page: https://pluginprobe.com/plugins/elementor/trunk/code/modules/atomic-widgets/css-converter/converters/number-property-converter.php
- Raw: https://pluginprobe.com/plugins/elementor/trunk/raw/modules/atomic-widgets/css-converter/converters/number-property-converter.php
- Modified: 2026-07-20T13:54:42+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/elementor/trunk/code/modules/atomic-widgets/css-converter/converters/number-property-converter.php#L10-L20`.

```php
<?php

namespace Elementor\Modules\AtomicWidgets\CssConverter\Converters;

use Elementor\Modules\AtomicWidgets\CssConverter\Conversion_Context;
use Elementor\Modules\AtomicWidgets\CssConverter\Property_Converter_Base;
use Elementor\Modules\AtomicWidgets\PropTypes\Primitives\Number_Prop_Type;

if ( ! defined( 'ABSPATH' ) ) {
	exit; // Exit if accessed directly.
}

/**
 * Reusable converter for properties backed by a Number_Prop_Type. One instance per property.
 * Accepts only a strict numeric value (no units, no functions); anything else declines (-> custom_css).
 * Emits the canonical Number PropValue from generate().
 */
class Number_Property_Converter extends Property_Converter_Base {
	private string $property;

	public function __construct( string $property ) {
		$this->property = $property;
	}

	protected function get_supported_properties(): array {
		return [ $this->property ];
	}

	protected function do_convert( Conversion_Context $context, array $rule ): bool {
		$value = trim( $rule['value'] );

		if ( ! is_numeric( $value ) ) {
			return false;
		}

		$context->set_prop( $this->property, Number_Prop_Type::generate( $value + 0 ) );

		return true;
	}
}

```
