| 1 |
<?php |
| 2 |
|
| 3 |
namespace Sellkit\Contact_Segmentation\Conditions; |
| 4 |
|
| 5 |
use Sellkit\Contact_Segmentation\Contact_Data; |
| 6 |
|
| 7 |
defined( 'ABSPATH' ) || die(); |
| 8 |
|
| 9 |
/** |
| 10 |
* Class Condition_Base. |
| 11 |
* |
| 12 |
* @package Sellkit\Contact_Segmentation\Base. |
| 13 |
* @since 1.1.0 |
| 14 |
* @SuppressWarnings(PHPMD.NumberOfChildren) |
| 15 |
*/ |
| 16 |
abstract class Condition_Base { |
| 17 |
|
| 18 |
const SELLKIT_DROP_DOWN_CONDITION_VALUE = 'drop-down'; |
| 19 |
const SELLKIT_TEXT_CONDITION_VALUE = 'text'; |
| 20 |
const SELLKIT_NUMBER_CONDITION_VALUE = 'number'; |
| 21 |
const SELLKIT_MULTISELECT_CONDITION_VALUE = 'multi-select'; |
| 22 |
const SELLKIT_REACT_SELECT_CONDITION_VALUE = 'react-select'; |
| 23 |
|
| 24 |
/** |
| 25 |
* Main contact data. |
| 26 |
* |
| 27 |
* @var Contact_Data |
| 28 |
* @since 1.1.0 |
| 29 |
*/ |
| 30 |
public $data; |
| 31 |
|
| 32 |
/** |
| 33 |
* Cart_Category constructor. |
| 34 |
* |
| 35 |
* @since 1.1.0 |
| 36 |
*/ |
| 37 |
public function __construct() { |
| 38 |
$contact_data = Contact_Data::get_instance(); |
| 39 |
|
| 40 |
$this->data = $contact_data->get_data(); |
| 41 |
} |
| 42 |
|
| 43 |
/** |
| 44 |
* Get title. |
| 45 |
* |
| 46 |
* @since 1.1.0 |
| 47 |
* @return string |
| 48 |
*/ |
| 49 |
abstract public function get_title(); |
| 50 |
|
| 51 |
/** |
| 52 |
* Get name. |
| 53 |
* |
| 54 |
* @since 1.1.0 |
| 55 |
* @return string |
| 56 |
*/ |
| 57 |
abstract public function get_name(); |
| 58 |
|
| 59 |
/** |
| 60 |
* Get type. |
| 61 |
* |
| 62 |
* @since 1.1.0 |
| 63 |
* @return string |
| 64 |
*/ |
| 65 |
abstract public function get_type(); |
| 66 |
|
| 67 |
/** |
| 68 |
* Get value. |
| 69 |
* |
| 70 |
* @since 1.1.0 |
| 71 |
*/ |
| 72 |
public function get_value() { |
| 73 |
if ( empty( $this->data[ str_replace( '-', '_', $this->get_name() ) ] ) ) { |
| 74 |
return ''; |
| 75 |
} |
| 76 |
|
| 77 |
return $this->data[ str_replace( '-', '_', $this->get_name() ) ]; |
| 78 |
} |
| 79 |
|
| 80 |
/** |
| 81 |
* It is pro or not. |
| 82 |
* |
| 83 |
* @since 1.1.0 |
| 84 |
*/ |
| 85 |
abstract public function is_pro(); |
| 86 |
|
| 87 |
/** |
| 88 |
* All the conditions are not searchable by default. |
| 89 |
* |
| 90 |
* @return false |
| 91 |
* @since 1.1.0 |
| 92 |
*/ |
| 93 |
public function is_searchable() { |
| 94 |
return false; |
| 95 |
} |
| 96 |
|
| 97 |
/** |
| 98 |
* Check if the condition is active or not, Conditions are active by default. |
| 99 |
* |
| 100 |
* @return bool |
| 101 |
*/ |
| 102 |
public function is_active() { |
| 103 |
return true; |
| 104 |
} |
| 105 |
} |
| 106 |
|