Completed
Branch dependabot/composer/tijsverkoy... (491ea6)
by
unknown
32:00 queued 25:42
created
core/services/notices/NoticeConverter.php 1 patch
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -11,71 +11,71 @@
 block discarded – undo
11 11
  */
12 12
 abstract class NoticeConverter implements NoticeConverterInterface
13 13
 {
14
-    /**
15
-     * @var NoticesContainerInterface $notices
16
-     */
17
-    private $notices;
14
+	/**
15
+	 * @var NoticesContainerInterface $notices
16
+	 */
17
+	private $notices;
18 18
 
19
-    /**
20
-     * if set to true, then errors will be thrown as exceptions
21
-     *
22
-     * @var boolean $throw_exceptions
23
-     */
24
-    private $throw_exceptions;
19
+	/**
20
+	 * if set to true, then errors will be thrown as exceptions
21
+	 *
22
+	 * @var boolean $throw_exceptions
23
+	 */
24
+	private $throw_exceptions;
25 25
 
26 26
 
27
-    /**
28
-     * NoticeConverter constructor.
29
-     *
30
-     * @param bool $throw_exceptions
31
-     */
32
-    public function __construct($throw_exceptions = false)
33
-    {
34
-        $this->throw_exceptions = $throw_exceptions;
35
-    }
27
+	/**
28
+	 * NoticeConverter constructor.
29
+	 *
30
+	 * @param bool $throw_exceptions
31
+	 */
32
+	public function __construct($throw_exceptions = false)
33
+	{
34
+		$this->throw_exceptions = $throw_exceptions;
35
+	}
36 36
 
37 37
 
38
-    /**
39
-     * @return NoticesContainerInterface
40
-     */
41
-    public function getNotices()
42
-    {
43
-        return $this->notices;
44
-    }
38
+	/**
39
+	 * @return NoticesContainerInterface
40
+	 */
41
+	public function getNotices()
42
+	{
43
+		return $this->notices;
44
+	}
45 45
 
46 46
 
47
-    /**
48
-     * @param NoticesContainerInterface $notices
49
-     */
50
-    protected function setNotices(NoticesContainerInterface $notices)
51
-    {
52
-        $this->notices = $notices;
53
-    }
47
+	/**
48
+	 * @param NoticesContainerInterface $notices
49
+	 */
50
+	protected function setNotices(NoticesContainerInterface $notices)
51
+	{
52
+		$this->notices = $notices;
53
+	}
54 54
 
55 55
 
56
-    /**
57
-     * @return bool
58
-     */
59
-    public function getThrowExceptions()
60
-    {
61
-        return $this->throw_exceptions;
62
-    }
56
+	/**
57
+	 * @return bool
58
+	 */
59
+	public function getThrowExceptions()
60
+	{
61
+		return $this->throw_exceptions;
62
+	}
63 63
 
64 64
 
65
-    /**
66
-     * @param bool $throw_exceptions
67
-     */
68
-    public function setThrowExceptions($throw_exceptions)
69
-    {
70
-        $this->throw_exceptions = filter_var($throw_exceptions, FILTER_VALIDATE_BOOLEAN);
71
-    }
65
+	/**
66
+	 * @param bool $throw_exceptions
67
+	 */
68
+	public function setThrowExceptions($throw_exceptions)
69
+	{
70
+		$this->throw_exceptions = filter_var($throw_exceptions, FILTER_VALIDATE_BOOLEAN);
71
+	}
72 72
 
73 73
 
74
-    /**
75
-     * @return void;
76
-     */
77
-    public function clearNotices()
78
-    {
79
-        $this->notices = null;
80
-    }
74
+	/**
75
+	 * @return void;
76
+	 */
77
+	public function clearNotices()
78
+	{
79
+		$this->notices = null;
80
+	}
81 81
 }
Please login to merge, or discard this patch.
core/services/notices/NoticeConverterInterface.php 1 patch
Indentation   +23 added lines, -23 removed lines patch added patch discarded remove patch
@@ -12,31 +12,31 @@
 block discarded – undo
12 12
  */
13 13
 interface NoticeConverterInterface
14 14
 {
15
-    /**
16
-     * @return NoticesContainerInterface
17
-     */
18
-    public function getNotices();
15
+	/**
16
+	 * @return NoticesContainerInterface
17
+	 */
18
+	public function getNotices();
19 19
 
20
-    /**
21
-     * @param bool $throw_exceptions
22
-     */
23
-    public function setThrowExceptions($throw_exceptions);
20
+	/**
21
+	 * @param bool $throw_exceptions
22
+	 */
23
+	public function setThrowExceptions($throw_exceptions);
24 24
 
25
-    /**
26
-     * @return bool
27
-     */
28
-    public function getThrowExceptions();
25
+	/**
26
+	 * @return bool
27
+	 */
28
+	public function getThrowExceptions();
29 29
 
30
-    /**
31
-     * Converts NoticesContainerInterface objects into other format
32
-     *
33
-     * @param NoticesContainerInterface $notices
34
-     * @return
35
-     */
36
-    public function process(NoticesContainerInterface $notices);
30
+	/**
31
+	 * Converts NoticesContainerInterface objects into other format
32
+	 *
33
+	 * @param NoticesContainerInterface $notices
34
+	 * @return
35
+	 */
36
+	public function process(NoticesContainerInterface $notices);
37 37
 
38
-    /**
39
-     * @return void;
40
-     */
41
-    public function clearNotices();
38
+	/**
39
+	 * @return void;
40
+	 */
41
+	public function clearNotices();
42 42
 }
Please login to merge, or discard this patch.
core/services/context/ContextChecker.php 1 patch
Indentation   +153 added lines, -153 removed lines patch added patch discarded remove patch
@@ -15,157 +15,157 @@
 block discarded – undo
15 15
  */
16 16
 class ContextChecker
17 17
 {
18
-    /**
19
-     * A unique string used to identify where this ContextChecker is being employed
20
-     * Is currently only used within the hook name for the filterable return value of isAllowed().
21
-     *
22
-     * @var string $identifier
23
-     */
24
-    private $identifier;
25
-
26
-    /**
27
-     * A list of values to be compared against the slug of the Context class passed to isAllowed()
28
-     *
29
-     * @var array $acceptable_values
30
-     */
31
-    private $acceptable_values;
32
-
33
-    /**
34
-     * Closure (or callable) that will be called to perform the evaluation within isAllowed().
35
-     * If none is provided, then a simple type sensitive in_array() check will be used
36
-     * and return true if the incoming Context::slug() is found within the array of $acceptable_values.
37
-     *
38
-     * @var callable $evaluation_callback
39
-     */
40
-    private $evaluation_callback;
41
-
42
-
43
-    /**
44
-     * ContextChecker constructor.
45
-     *
46
-     * @param string       $identifier
47
-     * @param array        $acceptable_values
48
-     * @param callable|null $evaluation_callback [optional]
49
-     */
50
-    public function __construct($identifier, array $acceptable_values, callable $evaluation_callback = null)
51
-    {
52
-        $this->setIdentifier($identifier);
53
-        $this->setAcceptableValues($acceptable_values);
54
-        $this->setEvaluationCallback($evaluation_callback);
55
-    }
56
-
57
-
58
-    /**
59
-     * @param string $identifier
60
-     */
61
-    private function setIdentifier($identifier)
62
-    {
63
-        $this->identifier = sanitize_key($identifier);
64
-    }
65
-
66
-
67
-    /**
68
-     * @param array $acceptable_values
69
-     */
70
-    private function setAcceptableValues(array $acceptable_values)
71
-    {
72
-        $this->acceptable_values = $acceptable_values;
73
-    }
74
-
75
-
76
-    /**
77
-     * @param callable $evaluation_callback
78
-     */
79
-    private function setEvaluationCallback(callable $evaluation_callback = null)
80
-    {
81
-        $this->evaluation_callback = is_callable($evaluation_callback)
82
-            ? $evaluation_callback
83
-            : [$this, 'evaluateContext'];
84
-    }
85
-
86
-
87
-    /**
88
-     * default callback for evaluating whether the supplied context exists within the supplied values
89
-     *
90
-     * @param ContextInterface $context
91
-     * @param array            $acceptable_values
92
-     * @return bool
93
-     * @since   4.10.14.p
94
-     */
95
-    public function evaluateContext(ContextInterface $context, array $acceptable_values = [])
96
-    {
97
-        return in_array($context->slug(), $acceptable_values, true);
98
-    }
99
-
100
-
101
-    /**
102
-     * @return string
103
-     */
104
-    protected function identifier()
105
-    {
106
-        return $this->identifier;
107
-    }
108
-
109
-
110
-    /**
111
-     * @return array
112
-     */
113
-    protected function acceptableValues()
114
-    {
115
-        return apply_filters(
116
-            "FHEE__EventEspresso_core_domain_entities_context_ContextChecker__{$this->identifier}__acceptableValues",
117
-            $this->acceptable_values
118
-        );
119
-    }
120
-
121
-
122
-    /**
123
-     * @return callable
124
-     */
125
-    protected function evaluationCallback()
126
-    {
127
-        return $this->evaluation_callback;
128
-    }
129
-
130
-
131
-    /**
132
-     * Returns true if the incoming Context class slug matches one of the preset acceptable values.
133
-     * The result is filterable using the identifier for this ContextChecker.
134
-     * example:
135
-     * If this ContextChecker's $identifier was set to "registration-checkout-type",
136
-     * then the filter here would be named:
137
-     *  "FHEE__EventEspresso_core_domain_entities_context_ContextChecker__registration-checkout-type__isAllowed".
138
-     * Other code could hook into the filter in isAllowed() using the above name
139
-     * and test for additional acceptable values.
140
-     * So if the set of $acceptable_values was: [ "initial-visit",  "revisit" ]
141
-     * then adding a filter to
142
-     *  "FHEE__EventEspresso_core_domain_entities_context_ContextChecker__registration-checkout-type__isAllowed",
143
-     * would allow you to perform your own conditional and allow "wait-list-checkout" as an acceptable value.
144
-     *  example:
145
-     *      add_filter(
146
-     *          'FHEE__EventEspresso_core_domain_entities_context_ContextChecker__registration-checkout-type__isAllowed',
147
-     *          function ($is_allowed, ContextInterface $context) { return $context->slug() === 'wait-list-checkout'
148
-     *                  ? true
149
-     *                  : $is_allowed;
150
-     *          },
151
-     *          10,
152
-     *          2
153
-     *      );
154
-     *
155
-     * @param ContextInterface $context
156
-     * @return boolean
157
-     */
158
-    public function isAllowed(ContextInterface $context)
159
-    {
160
-        $evaluation_callback = $this->evaluationCallback();
161
-        return filter_var(
162
-            apply_filters(
163
-                "FHEE__EventEspresso_core_domain_entities_context_ContextChecker__{$this->identifier}__isAllowed",
164
-                $evaluation_callback($context, $this->acceptableValues()),
165
-                $context,
166
-                $this
167
-            ),
168
-            FILTER_VALIDATE_BOOLEAN
169
-        );
170
-    }
18
+	/**
19
+	 * A unique string used to identify where this ContextChecker is being employed
20
+	 * Is currently only used within the hook name for the filterable return value of isAllowed().
21
+	 *
22
+	 * @var string $identifier
23
+	 */
24
+	private $identifier;
25
+
26
+	/**
27
+	 * A list of values to be compared against the slug of the Context class passed to isAllowed()
28
+	 *
29
+	 * @var array $acceptable_values
30
+	 */
31
+	private $acceptable_values;
32
+
33
+	/**
34
+	 * Closure (or callable) that will be called to perform the evaluation within isAllowed().
35
+	 * If none is provided, then a simple type sensitive in_array() check will be used
36
+	 * and return true if the incoming Context::slug() is found within the array of $acceptable_values.
37
+	 *
38
+	 * @var callable $evaluation_callback
39
+	 */
40
+	private $evaluation_callback;
41
+
42
+
43
+	/**
44
+	 * ContextChecker constructor.
45
+	 *
46
+	 * @param string       $identifier
47
+	 * @param array        $acceptable_values
48
+	 * @param callable|null $evaluation_callback [optional]
49
+	 */
50
+	public function __construct($identifier, array $acceptable_values, callable $evaluation_callback = null)
51
+	{
52
+		$this->setIdentifier($identifier);
53
+		$this->setAcceptableValues($acceptable_values);
54
+		$this->setEvaluationCallback($evaluation_callback);
55
+	}
56
+
57
+
58
+	/**
59
+	 * @param string $identifier
60
+	 */
61
+	private function setIdentifier($identifier)
62
+	{
63
+		$this->identifier = sanitize_key($identifier);
64
+	}
65
+
66
+
67
+	/**
68
+	 * @param array $acceptable_values
69
+	 */
70
+	private function setAcceptableValues(array $acceptable_values)
71
+	{
72
+		$this->acceptable_values = $acceptable_values;
73
+	}
74
+
75
+
76
+	/**
77
+	 * @param callable $evaluation_callback
78
+	 */
79
+	private function setEvaluationCallback(callable $evaluation_callback = null)
80
+	{
81
+		$this->evaluation_callback = is_callable($evaluation_callback)
82
+			? $evaluation_callback
83
+			: [$this, 'evaluateContext'];
84
+	}
85
+
86
+
87
+	/**
88
+	 * default callback for evaluating whether the supplied context exists within the supplied values
89
+	 *
90
+	 * @param ContextInterface $context
91
+	 * @param array            $acceptable_values
92
+	 * @return bool
93
+	 * @since   4.10.14.p
94
+	 */
95
+	public function evaluateContext(ContextInterface $context, array $acceptable_values = [])
96
+	{
97
+		return in_array($context->slug(), $acceptable_values, true);
98
+	}
99
+
100
+
101
+	/**
102
+	 * @return string
103
+	 */
104
+	protected function identifier()
105
+	{
106
+		return $this->identifier;
107
+	}
108
+
109
+
110
+	/**
111
+	 * @return array
112
+	 */
113
+	protected function acceptableValues()
114
+	{
115
+		return apply_filters(
116
+			"FHEE__EventEspresso_core_domain_entities_context_ContextChecker__{$this->identifier}__acceptableValues",
117
+			$this->acceptable_values
118
+		);
119
+	}
120
+
121
+
122
+	/**
123
+	 * @return callable
124
+	 */
125
+	protected function evaluationCallback()
126
+	{
127
+		return $this->evaluation_callback;
128
+	}
129
+
130
+
131
+	/**
132
+	 * Returns true if the incoming Context class slug matches one of the preset acceptable values.
133
+	 * The result is filterable using the identifier for this ContextChecker.
134
+	 * example:
135
+	 * If this ContextChecker's $identifier was set to "registration-checkout-type",
136
+	 * then the filter here would be named:
137
+	 *  "FHEE__EventEspresso_core_domain_entities_context_ContextChecker__registration-checkout-type__isAllowed".
138
+	 * Other code could hook into the filter in isAllowed() using the above name
139
+	 * and test for additional acceptable values.
140
+	 * So if the set of $acceptable_values was: [ "initial-visit",  "revisit" ]
141
+	 * then adding a filter to
142
+	 *  "FHEE__EventEspresso_core_domain_entities_context_ContextChecker__registration-checkout-type__isAllowed",
143
+	 * would allow you to perform your own conditional and allow "wait-list-checkout" as an acceptable value.
144
+	 *  example:
145
+	 *      add_filter(
146
+	 *          'FHEE__EventEspresso_core_domain_entities_context_ContextChecker__registration-checkout-type__isAllowed',
147
+	 *          function ($is_allowed, ContextInterface $context) { return $context->slug() === 'wait-list-checkout'
148
+	 *                  ? true
149
+	 *                  : $is_allowed;
150
+	 *          },
151
+	 *          10,
152
+	 *          2
153
+	 *      );
154
+	 *
155
+	 * @param ContextInterface $context
156
+	 * @return boolean
157
+	 */
158
+	public function isAllowed(ContextInterface $context)
159
+	{
160
+		$evaluation_callback = $this->evaluationCallback();
161
+		return filter_var(
162
+			apply_filters(
163
+				"FHEE__EventEspresso_core_domain_entities_context_ContextChecker__{$this->identifier}__isAllowed",
164
+				$evaluation_callback($context, $this->acceptableValues()),
165
+				$context,
166
+				$this
167
+			),
168
+			FILTER_VALIDATE_BOOLEAN
169
+		);
170
+	}
171 171
 }
Please login to merge, or discard this patch.
core/services/progress_steps/ProgressStepsConfigInterface.php 1 patch
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -10,7 +10,7 @@
 block discarded – undo
10 10
  */
11 11
 interface ProgressStepsConfigInterface
12 12
 {
13
-    public function get();
13
+	public function get();
14 14
 
15
-    public function update();
15
+	public function update();
16 16
 }
Please login to merge, or discard this patch.
progress_steps/display_strategies/ProgressStepsDisplayInterface.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -11,23 +11,23 @@
 block discarded – undo
11 11
  */
12 12
 interface ProgressStepsDisplayInterface
13 13
 {
14
-    /**
15
-     * used for setting up css and js required for the display strategy
16
-     * ** IMPORTANT **
17
-     * This needs to be called BEFORE the wp_enqueue_scripts hook point for the frontend
18
-     * or the admin_enqueue_scripts in the admin.
19
-     * If setting up steps for the admin, this can be done via the
20
-     * 'FHEE__EE_Admin_Page___load_page_dependencies__after_load' ACTION
21
-     * in \EE_Admin_Page::_load_page_dependencies() or the targeted hook that comes after it
22
-     *
23
-     * @return void
24
-     */
25
-    public function enqueueStylesAndScripts();
14
+	/**
15
+	 * used for setting up css and js required for the display strategy
16
+	 * ** IMPORTANT **
17
+	 * This needs to be called BEFORE the wp_enqueue_scripts hook point for the frontend
18
+	 * or the admin_enqueue_scripts in the admin.
19
+	 * If setting up steps for the admin, this can be done via the
20
+	 * 'FHEE__EE_Admin_Page___load_page_dependencies__after_load' ACTION
21
+	 * in \EE_Admin_Page::_load_page_dependencies() or the targeted hook that comes after it
22
+	 *
23
+	 * @return void
24
+	 */
25
+	public function enqueueStylesAndScripts();
26 26
 
27
-    /**
28
-     * loads and returns a full server path to the template used for the display strategy
29
-     *
30
-     * @return string
31
-     */
32
-    public function getTemplate();
27
+	/**
28
+	 * loads and returns a full server path to the template used for the display strategy
29
+	 *
30
+	 * @return string
31
+	 */
32
+	public function getTemplate();
33 33
 }
Please login to merge, or discard this patch.
core/services/progress_steps/ProgressStepInterface.php 1 patch
Indentation   +24 added lines, -24 removed lines patch added patch discarded remove patch
@@ -11,33 +11,33 @@
 block discarded – undo
11 11
  */
12 12
 interface ProgressStepInterface
13 13
 {
14
-    /**
15
-     * @return boolean
16
-     */
17
-    public function isCurrent();
14
+	/**
15
+	 * @return boolean
16
+	 */
17
+	public function isCurrent();
18 18
 
19
-    /**
20
-     * @param boolean $is_current
21
-     */
22
-    public function setIsCurrent($is_current = true);
19
+	/**
20
+	 * @param boolean $is_current
21
+	 */
22
+	public function setIsCurrent($is_current = true);
23 23
 
24
-    /**
25
-     * @return string
26
-     */
27
-    public function id();
24
+	/**
25
+	 * @return string
26
+	 */
27
+	public function id();
28 28
 
29
-    /**
30
-     * @return int
31
-     */
32
-    public function order();
29
+	/**
30
+	 * @return int
31
+	 */
32
+	public function order();
33 33
 
34
-    /**
35
-     * @return string
36
-     */
37
-    public function htmlClass();
34
+	/**
35
+	 * @return string
36
+	 */
37
+	public function htmlClass();
38 38
 
39
-    /**
40
-     * @return string
41
-     */
42
-    public function text();
39
+	/**
40
+	 * @return string
41
+	 */
42
+	public function text();
43 43
 }
Please login to merge, or discard this patch.
core/services/progress_steps/ProgressStepCollection.php 1 patch
Indentation   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -16,13 +16,13 @@
 block discarded – undo
16 16
  */
17 17
 class ProgressStepCollection extends Collection
18 18
 {
19
-    /**
20
-     * ProgressStepCollection constructor.
21
-     *
22
-     * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
23
-     */
24
-    public function __construct()
25
-    {
26
-        parent::__construct('\EventEspresso\core\services\progress_steps\ProgressStepInterface');
27
-    }
19
+	/**
20
+	 * ProgressStepCollection constructor.
21
+	 *
22
+	 * @throws \EventEspresso\core\exceptions\InvalidInterfaceException
23
+	 */
24
+	public function __construct()
25
+	{
26
+		parent::__construct('\EventEspresso\core\services\progress_steps\ProgressStepInterface');
27
+	}
28 28
 }
Please login to merge, or discard this patch.
core/services/form/meta/Required.php 1 patch
Indentation   +106 added lines, -106 removed lines patch added patch discarded remove patch
@@ -14,110 +14,110 @@
 block discarded – undo
14 14
  */
15 15
 class Required implements JsonableInterface
16 16
 {
17
-    /**
18
-     * @var JsonDataHandler
19
-     */
20
-    private $json_data_handler;
21
-
22
-    /** Whether or not the input must be supplied with a value in order to complete the form.
23
-     *
24
-     * @var bool
25
-     */
26
-    private $required;
27
-
28
-    /**
29
-     * Custom validation text displayed alongside a required form input to assist users with completing the form.
30
-     *
31
-     * @var string
32
-     */
33
-    private $validationText;
34
-
35
-
36
-    /**
37
-     * Required constructor.
38
-     *
39
-     * @param JsonDataHandler $json_data_handler
40
-     * @param bool            $required
41
-     * @param string          $validationText
42
-     */
43
-    public function __construct(JsonDataHandler $json_data_handler, bool $required, string $validationText)
44
-    {
45
-        $this->json_data_handler = $json_data_handler;
46
-        $this->setRequired($required);
47
-        $this->setValidationText($validationText);
48
-    }
49
-
50
-
51
-    /**
52
-     * @param string $json
53
-     * @return Required
54
-     */
55
-    public static function fromJson(string $json): Required
56
-    {
57
-        $json_data_handler = new JsonDataHandler();
58
-        $json_data_handler->configure(JsonDataHandler::DATA_TYPE_OBJECT);
59
-        $data           = $json_data_handler->decodeJson($json);
60
-        $required       = $data->required ?? false;
61
-        $validationText = $data->validationText ?? '';
62
-        return new Required($json_data_handler, $required, $validationText);
63
-    }
64
-
65
-
66
-    /**
67
-     * @return array
68
-     */
69
-    public function toArray(): array
70
-    {
71
-        return [
72
-            'required'       => $this->required,
73
-            'validationText' => $this->validationText,
74
-        ];
75
-    }
76
-
77
-
78
-    /**
79
-     * @return string
80
-     */
81
-    public function toJson(): string
82
-    {
83
-        return $this->json_data_handler->encodeData($this->toArray());
84
-    }
85
-
86
-
87
-    /**
88
-     *
89
-     *
90
-     * @return bool
91
-     */
92
-    public function isRequired(): ?bool
93
-    {
94
-        return $this->required;
95
-    }
96
-
97
-
98
-    /**
99
-     * @param bool|int|string $required
100
-     */
101
-    public function setRequired($required = true)
102
-    {
103
-        $this->required = filter_var($required, FILTER_VALIDATE_BOOLEAN);
104
-    }
105
-
106
-
107
-    /**
108
-     * @return string
109
-     */
110
-    public function validationText(): ?string
111
-    {
112
-        return $this->validationText;
113
-    }
114
-
115
-
116
-    /**
117
-     * @param string $validationText
118
-     */
119
-    public function setValidationText(string $validationText)
120
-    {
121
-        $this->validationText = sanitize_text_field($validationText);
122
-    }
17
+	/**
18
+	 * @var JsonDataHandler
19
+	 */
20
+	private $json_data_handler;
21
+
22
+	/** Whether or not the input must be supplied with a value in order to complete the form.
23
+	 *
24
+	 * @var bool
25
+	 */
26
+	private $required;
27
+
28
+	/**
29
+	 * Custom validation text displayed alongside a required form input to assist users with completing the form.
30
+	 *
31
+	 * @var string
32
+	 */
33
+	private $validationText;
34
+
35
+
36
+	/**
37
+	 * Required constructor.
38
+	 *
39
+	 * @param JsonDataHandler $json_data_handler
40
+	 * @param bool            $required
41
+	 * @param string          $validationText
42
+	 */
43
+	public function __construct(JsonDataHandler $json_data_handler, bool $required, string $validationText)
44
+	{
45
+		$this->json_data_handler = $json_data_handler;
46
+		$this->setRequired($required);
47
+		$this->setValidationText($validationText);
48
+	}
49
+
50
+
51
+	/**
52
+	 * @param string $json
53
+	 * @return Required
54
+	 */
55
+	public static function fromJson(string $json): Required
56
+	{
57
+		$json_data_handler = new JsonDataHandler();
58
+		$json_data_handler->configure(JsonDataHandler::DATA_TYPE_OBJECT);
59
+		$data           = $json_data_handler->decodeJson($json);
60
+		$required       = $data->required ?? false;
61
+		$validationText = $data->validationText ?? '';
62
+		return new Required($json_data_handler, $required, $validationText);
63
+	}
64
+
65
+
66
+	/**
67
+	 * @return array
68
+	 */
69
+	public function toArray(): array
70
+	{
71
+		return [
72
+			'required'       => $this->required,
73
+			'validationText' => $this->validationText,
74
+		];
75
+	}
76
+
77
+
78
+	/**
79
+	 * @return string
80
+	 */
81
+	public function toJson(): string
82
+	{
83
+		return $this->json_data_handler->encodeData($this->toArray());
84
+	}
85
+
86
+
87
+	/**
88
+	 *
89
+	 *
90
+	 * @return bool
91
+	 */
92
+	public function isRequired(): ?bool
93
+	{
94
+		return $this->required;
95
+	}
96
+
97
+
98
+	/**
99
+	 * @param bool|int|string $required
100
+	 */
101
+	public function setRequired($required = true)
102
+	{
103
+		$this->required = filter_var($required, FILTER_VALIDATE_BOOLEAN);
104
+	}
105
+
106
+
107
+	/**
108
+	 * @return string
109
+	 */
110
+	public function validationText(): ?string
111
+	{
112
+		return $this->validationText;
113
+	}
114
+
115
+
116
+	/**
117
+	 * @param string $validationText
118
+	 */
119
+	public function setValidationText(string $validationText)
120
+	{
121
+		$this->validationText = sanitize_text_field($validationText);
122
+	}
123 123
 }
Please login to merge, or discard this patch.
core/services/form/meta/FormLabel.php 1 patch
Indentation   +169 added lines, -169 removed lines patch added patch discarded remove patch
@@ -14,173 +14,173 @@
 block discarded – undo
14 14
  */
15 15
 class FormLabel implements JsonableInterface
16 16
 {
17
-    /**
18
-     * @var JsonDataHandler
19
-     */
20
-    private $json_data_handler;
21
-
22
-    /**
23
-     * Input label displayed in the admin to help differentiate input from others
24
-     *
25
-     * @var string
26
-     */
27
-    private $adminLabel;
28
-
29
-    /**
30
-     * Input label displayed on public forms, ie: the actual question text.
31
-     *
32
-     * @var string
33
-     */
34
-    private $publicLabel;
35
-
36
-    /**
37
-     * @var bool
38
-     */
39
-    private $showLabel;
40
-
41
-    /**
42
-     * The HTML block displayed for block elements.
43
-     *
44
-     * @var string
45
-     */
46
-    private $html;
47
-
48
-
49
-    /**
50
-     * FormLabel constructor.
51
-     *
52
-     * @param JsonDataHandler $json_data_handler
53
-     * @param string          $adminLabel
54
-     * @param string          $publicLabel
55
-     * @param bool            $showLabel
56
-     */
57
-    public function __construct(
58
-        JsonDataHandler $json_data_handler,
59
-        string $adminLabel,
60
-        string $publicLabel,
61
-        bool $showLabel,
62
-        string $html
63
-    ) {
64
-        $this->json_data_handler = $json_data_handler;
65
-        $this->setAdminLabel($adminLabel);
66
-        $this->setPublicLabel($publicLabel);
67
-        $this->setShowLabel($showLabel);
68
-        $this->setHtml($html);
69
-    }
70
-
71
-
72
-    /**
73
-     * @param string $json
74
-     * @return FormLabel
75
-     */
76
-    public static function fromJson(string $json): FormLabel
77
-    {
78
-        $json_data_handler = new JsonDataHandler();
79
-        $json_data_handler->configure(JsonDataHandler::DATA_TYPE_OBJECT);
80
-        $data        = $json_data_handler->decodeJson($json);
81
-        $adminLabel  = $data->adminLabel ?? '';
82
-        $publicLabel = $data->publicLabel ?? '';
83
-        $showLabel   = $data->showLabel ?? false;
84
-        $html        = $data->html ?? '';
85
-        return new FormLabel($json_data_handler, $adminLabel, $publicLabel, $showLabel, $html);
86
-    }
87
-
88
-
89
-    /**
90
-     * @return array
91
-     */
92
-    public function toArray(): array
93
-    {
94
-        return [
95
-            'adminLabel'  => $this->adminLabel,
96
-            'publicLabel' => $this->publicLabel,
97
-            'showLabel'   => $this->showLabel,
98
-            'html'        => $this->html,
99
-        ];
100
-    }
101
-
102
-
103
-    /**
104
-     * @return string
105
-     */
106
-    public function toJson(): string
107
-    {
108
-        return $this->json_data_handler->encodeData($this->toArray());
109
-    }
110
-
111
-
112
-    /**
113
-     * Input label displayed in the admin to help differentiate input from others
114
-     *
115
-     * @return string
116
-     */
117
-    public function adminLabel(): string
118
-    {
119
-        return $this->adminLabel;
120
-    }
121
-
122
-
123
-    /**
124
-     * @param string $adminLabel
125
-     */
126
-    public function setAdminLabel(string $adminLabel): void
127
-    {
128
-        $this->adminLabel = sanitize_text_field($adminLabel);
129
-    }
130
-
131
-
132
-    /**
133
-     * Input label displayed on public forms, ie: the actual question text.
134
-     *
135
-     * @return string
136
-     */
137
-    public function publicLabel(): string
138
-    {
139
-        return $this->publicLabel;
140
-    }
141
-
142
-
143
-    /**
144
-     * @param string $publicLabel
145
-     */
146
-    public function setPublicLabel(string $publicLabel): void
147
-    {
148
-        $this->publicLabel = sanitize_text_field($publicLabel);
149
-    }
150
-
151
-
152
-    /**
153
-     * @return bool
154
-     */
155
-    public function showLabel(): bool
156
-    {
157
-        return $this->showLabel;
158
-    }
159
-
160
-
161
-    /**
162
-     * @param bool|int|string $showLabel
163
-     */
164
-    public function setShowLabel($showLabel): void
165
-    {
166
-        $this->showLabel = filter_var($showLabel, FILTER_VALIDATE_BOOLEAN);
167
-    }
168
-
169
-
170
-    /**
171
-     * @return string
172
-     */
173
-    public function html(): string
174
-    {
175
-        return $this->html;
176
-    }
177
-
178
-
179
-    /**
180
-     * @param string $html
181
-     */
182
-    public function setHtml(string $html): void
183
-    {
184
-        $this->html = wp_kses_post($html);
185
-    }
17
+	/**
18
+	 * @var JsonDataHandler
19
+	 */
20
+	private $json_data_handler;
21
+
22
+	/**
23
+	 * Input label displayed in the admin to help differentiate input from others
24
+	 *
25
+	 * @var string
26
+	 */
27
+	private $adminLabel;
28
+
29
+	/**
30
+	 * Input label displayed on public forms, ie: the actual question text.
31
+	 *
32
+	 * @var string
33
+	 */
34
+	private $publicLabel;
35
+
36
+	/**
37
+	 * @var bool
38
+	 */
39
+	private $showLabel;
40
+
41
+	/**
42
+	 * The HTML block displayed for block elements.
43
+	 *
44
+	 * @var string
45
+	 */
46
+	private $html;
47
+
48
+
49
+	/**
50
+	 * FormLabel constructor.
51
+	 *
52
+	 * @param JsonDataHandler $json_data_handler
53
+	 * @param string          $adminLabel
54
+	 * @param string          $publicLabel
55
+	 * @param bool            $showLabel
56
+	 */
57
+	public function __construct(
58
+		JsonDataHandler $json_data_handler,
59
+		string $adminLabel,
60
+		string $publicLabel,
61
+		bool $showLabel,
62
+		string $html
63
+	) {
64
+		$this->json_data_handler = $json_data_handler;
65
+		$this->setAdminLabel($adminLabel);
66
+		$this->setPublicLabel($publicLabel);
67
+		$this->setShowLabel($showLabel);
68
+		$this->setHtml($html);
69
+	}
70
+
71
+
72
+	/**
73
+	 * @param string $json
74
+	 * @return FormLabel
75
+	 */
76
+	public static function fromJson(string $json): FormLabel
77
+	{
78
+		$json_data_handler = new JsonDataHandler();
79
+		$json_data_handler->configure(JsonDataHandler::DATA_TYPE_OBJECT);
80
+		$data        = $json_data_handler->decodeJson($json);
81
+		$adminLabel  = $data->adminLabel ?? '';
82
+		$publicLabel = $data->publicLabel ?? '';
83
+		$showLabel   = $data->showLabel ?? false;
84
+		$html        = $data->html ?? '';
85
+		return new FormLabel($json_data_handler, $adminLabel, $publicLabel, $showLabel, $html);
86
+	}
87
+
88
+
89
+	/**
90
+	 * @return array
91
+	 */
92
+	public function toArray(): array
93
+	{
94
+		return [
95
+			'adminLabel'  => $this->adminLabel,
96
+			'publicLabel' => $this->publicLabel,
97
+			'showLabel'   => $this->showLabel,
98
+			'html'        => $this->html,
99
+		];
100
+	}
101
+
102
+
103
+	/**
104
+	 * @return string
105
+	 */
106
+	public function toJson(): string
107
+	{
108
+		return $this->json_data_handler->encodeData($this->toArray());
109
+	}
110
+
111
+
112
+	/**
113
+	 * Input label displayed in the admin to help differentiate input from others
114
+	 *
115
+	 * @return string
116
+	 */
117
+	public function adminLabel(): string
118
+	{
119
+		return $this->adminLabel;
120
+	}
121
+
122
+
123
+	/**
124
+	 * @param string $adminLabel
125
+	 */
126
+	public function setAdminLabel(string $adminLabel): void
127
+	{
128
+		$this->adminLabel = sanitize_text_field($adminLabel);
129
+	}
130
+
131
+
132
+	/**
133
+	 * Input label displayed on public forms, ie: the actual question text.
134
+	 *
135
+	 * @return string
136
+	 */
137
+	public function publicLabel(): string
138
+	{
139
+		return $this->publicLabel;
140
+	}
141
+
142
+
143
+	/**
144
+	 * @param string $publicLabel
145
+	 */
146
+	public function setPublicLabel(string $publicLabel): void
147
+	{
148
+		$this->publicLabel = sanitize_text_field($publicLabel);
149
+	}
150
+
151
+
152
+	/**
153
+	 * @return bool
154
+	 */
155
+	public function showLabel(): bool
156
+	{
157
+		return $this->showLabel;
158
+	}
159
+
160
+
161
+	/**
162
+	 * @param bool|int|string $showLabel
163
+	 */
164
+	public function setShowLabel($showLabel): void
165
+	{
166
+		$this->showLabel = filter_var($showLabel, FILTER_VALIDATE_BOOLEAN);
167
+	}
168
+
169
+
170
+	/**
171
+	 * @return string
172
+	 */
173
+	public function html(): string
174
+	{
175
+		return $this->html;
176
+	}
177
+
178
+
179
+	/**
180
+	 * @param string $html
181
+	 */
182
+	public function setHtml(string $html): void
183
+	{
184
+		$this->html = wp_kses_post($html);
185
+	}
186 186
 }
Please login to merge, or discard this patch.