| 1 |
<?php |
| 2 |
|
| 3 |
|
| 4 |
namespace Jet_Form_Builder\Blocks\Conditional_Block\Operators; |
| 5 |
|
| 6 |
use Jet_Form_Builder\Blocks\Conditional_Block\Condition_Response_Object; |
| 7 |
use Jet_Form_Builder\Blocks\Conditional_Block\Condition_Types\Base_Condition_Type; |
| 8 |
use Jet_Form_Builder\Classes\Arrayable\Arrayable; |
| 9 |
use JFB_Components\Repository\Repository_Item_Instance_Trait; |
| 10 |
|
| 11 |
// If this file is called directly, abort. |
| 12 |
if ( ! defined( 'WPINC' ) ) { |
| 13 |
die; |
| 14 |
} |
| 15 |
|
| 16 |
abstract class Base_Operator implements |
| 17 |
Repository_Item_Instance_Trait, |
| 18 |
Arrayable, |
| 19 |
Condition_Response_Object { |
| 20 |
|
| 21 |
abstract public function get_id(): string; |
| 22 |
|
| 23 |
abstract public function get_title(): string; |
| 24 |
|
| 25 |
abstract public function is_supported(): bool; |
| 26 |
|
| 27 |
public function rep_item_id() { |
| 28 |
return $this->get_id(); |
| 29 |
} |
| 30 |
|
| 31 |
protected function check( Base_Condition_Type $item ): bool { |
| 32 |
return true; |
| 33 |
} |
| 34 |
|
| 35 |
public function to_response( array $base, Base_Condition_Type $item ): array { |
| 36 |
if ( ! $this->is_supported() ) { |
| 37 |
return array(); |
| 38 |
} |
| 39 |
|
| 40 |
return array( |
| 41 |
'check_result' => $this->check( $item ), |
| 42 |
); |
| 43 |
} |
| 44 |
|
| 45 |
public function to_array(): array { |
| 46 |
return array( |
| 47 |
'label' => $this->get_title(), |
| 48 |
'value' => $this->get_id(), |
| 49 |
); |
| 50 |
} |
| 51 |
|
| 52 |
} |
| 53 |
|