PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.16.8.1
GiveWP – Donation Plugin and Fundraising Platform v4.16.8.1
4.16.9 4.16.8.1 4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 All 255 releases
give / src / Framework / FieldsAPI / Concerns / HasMaxLength.php

HasMaxLength.php in GiveWP – Donation Plugin and Fundraising Platform 4.16.8.1, at src/Framework/FieldsAPI/Concerns/HasMaxLength.php

50 lines 988 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Give\Framework\FieldsAPI\Concerns;
4
5
6 use Give\Vendors\StellarWP\Validation\Rules\Max;
7
8 /**
9 * @since 2.24.0 update to new validation system
10 * @since 2.14.0
11 */
12 trait HasMaxLength
13 {
14 /**
15 * Set the value’s maximum length.
16 *
17 * @since 2.24.0 update to use the new validation system
18 * @since 2.14.0
19 */
20 public function maxLength(int $maxLength): self
21 {
22 if ( $this->hasRule('max') ) {
23 /** @var Max $rule */
24 $rule = $this->getRule('max');
25 $rule->size($maxLength);
26 }
27
28 $this->rules("max:$maxLength");
29
30 return $this;
31 }
32
33 /**
34 * Get the value’s maximum length.
35 *
36 * @since 2.24.0 update to use the new validation system
37 * @since 2.14.0
38 *
39 * @return int|null
40 */
41 public function getMaxLength()
42 {
43 if ( !$this->hasRule('max') ) {
44 return null;
45 }
46
47 return $this->getRule('max')->getSize();
48 }
49 }
50