cloggier
↑
/wp-content/plugins/wpforms-sendinblue/src/Provider
marsupiataab
hypermuffing
cloggier
hypermuffing
marsupiataab
BaseField.php
2,723 B
cloggier
marsupiataab
DefaultField.php
2,670 B
cloggier
marsupiataab
FieldMapper.php
5,091 B
cloggier
marsupiataab
LikertScaleField.php
1,240 B
cloggier
marsupiataab
NameField.php
848 B
cloggier
marsupiataab
PasswordField.php
895 B
cloggier
marsupiataab
<?php namespace WPFormsSendinblue\Provider\CustomFields; /** * Class BaseField. * * @since 1.0.0 */ abstract class BaseField { /** * Field attributes. * * @since 1.0.0 * * @var array */ protected $field; /** * Field settings. * * @since 1.0.0 * * @var array */ protected $settings; /** * Attribute information. * * @since 1.0.0 * * @var array */ protected $attribute; /** * BaseField constructor. * * @since 1.0.0 * * @param array $field Field attributes. * @param array $settings Field settings. * @param array $attribute Current attribute. */ public function __construct( $field, $settings, $attribute ) { $this->field = $field; $this->settings = $settings; $this->attribute = $attribute; } /** * Text format. * * @since 1.0.0 * * @return string */ abstract protected function text(); /** * Date format. * * @since 1.0.0 * * @return string|null */ abstract protected function date(); /** * Number format. * * @since 1.0.0 * * @return float|null */ abstract protected function float(); /** * Category format. * * @since 1.0.0 * * @return int|null */ abstract protected function category(); /** * Boolean format. * * @since 1.0.0 * * @return bool */ abstract protected function boolean(); /** * Phone format. * * @since 1.0.0 * * @return string|null */ abstract protected function phone(); /** * Multiple choices format. * * @since 1.4.0 * * @return array */ abstract protected function multiple_choice(): array; /** * Get an attribute type. * * @since 1.0.0 * * @return string */ private function get_attribute_type() { if ( ! empty( $this->attribute['name'] ) && 'SMS' === $this->attribute['name'] ) { return 'phone'; } if ( ! empty( $this->attribute['type'] ) ) { // The type could be named 'multiple-choices' that is not a valid method name. return str_replace( '-', '_', $this->attribute['type'] ); } if ( ! empty( $this->attribute['category'] ) ) { return 'category'; } return ''; } /** * Get value. * * @since 1.0.0 */ public function value() { $type = $this->get_attribute_type(); if ( ! $type || ! method_exists( $this, $type ) ) { return null; } $value = $this->{$type}(); if ( is_null( $value ) ) { return null; } if ( is_bool( $value ) ) { return $value; } if ( is_array( $value ) ) { return array_map( static function ( $single_value ) { return wpforms_decode_string( trim( $single_value ) ); }, $value ); } return str_replace( [ "\r\n", "\r", "\n" ], ', ', wpforms_decode_string( $value ) ); } }
cloggier