| 1 |
<?php |
| 2 |
|
| 3 |
namespace Elementor\Modules\AtomicWidgets\CssConverter; |
| 4 |
|
| 5 |
if ( ! defined( 'ABSPATH' ) ) { |
| 6 |
exit; // Exit if accessed directly. |
| 7 |
} |
| 8 |
|
| 9 |
class Conversion_Context { |
| 10 |
private array $props = []; |
| 11 |
|
| 12 |
private array $rejected = []; |
| 13 |
|
| 14 |
private array $rules; |
| 15 |
|
| 16 |
private array $global_variables; |
| 17 |
|
| 18 |
/** |
| 19 |
* @param array<int, array{property: string, value: string}> $rules The full set of sibling declarations. |
| 20 |
* @param array $global_variables Wired for forward compatibility, empty in v1. |
| 21 |
*/ |
| 22 |
public function __construct( array $rules = [], array $global_variables = [] ) { |
| 23 |
$this->rules = $rules; |
| 24 |
$this->global_variables = $global_variables; |
| 25 |
} |
| 26 |
|
| 27 |
/** |
| 28 |
* @return array<int, array{property: string, value: string}> |
| 29 |
*/ |
| 30 |
public function get_rules(): array { |
| 31 |
return $this->rules; |
| 32 |
} |
| 33 |
|
| 34 |
public function get_global_variables(): array { |
| 35 |
return $this->global_variables; |
| 36 |
} |
| 37 |
|
| 38 |
public function get_props(): array { |
| 39 |
return $this->props; |
| 40 |
} |
| 41 |
|
| 42 |
public function has_prop( string $property ): bool { |
| 43 |
return array_key_exists( $property, $this->props ); |
| 44 |
} |
| 45 |
|
| 46 |
/** |
| 47 |
* @return mixed |
| 48 |
*/ |
| 49 |
public function get_prop( string $property ) { |
| 50 |
return $this->props[ $property ] ?? null; |
| 51 |
} |
| 52 |
|
| 53 |
/** |
| 54 |
* @param string $property The output property name the converter owns. |
| 55 |
* @param mixed $value The canonical PropValue contributed for the property. |
| 56 |
*/ |
| 57 |
public function set_prop( string $property, $value ): void { |
| 58 |
$this->props[ $property ] = $value; |
| 59 |
} |
| 60 |
|
| 61 |
public function reject( string $declaration ): void { |
| 62 |
$this->rejected[] = $declaration; |
| 63 |
} |
| 64 |
|
| 65 |
public function get_rejected(): array { |
| 66 |
return $this->rejected; |
| 67 |
} |
| 68 |
} |
| 69 |
|