PluginProbe
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder / 4.3.6
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder v4.3.6
6.2.14 6.2.13 6.2.12 6.2.10 6.2.11 6.2.9 6.2.8 6.2.7 6.2.6 6.2.5 6.2.4 6.2.3 6.2.2 3.6.22 3.6.31 3.6.40 3.6.41 3.6.42 3.6.50 3.6.51 3.6.60 3.6.61 3.6.62 3.6.64 3.6.65 All 196 releases
fluentform / app / Helpers / Str.php

Str.php in Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder 4.3.6, at app/Helpers/Str.php

84 lines 2.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentForm\App\Helpers;
4
5 class Str
6 {
7 /**
8 * Determine if a given string starts with a given substring.
9 *
10 * @param string $haystack
11 * @param string|array $needles
12 * @return bool
13 */
14 public static function startsWith($haystack, $needles)
15 {
16 if(is_array($haystack)) {
17 $haystack = implode(' ', $haystack);
18 }
19
20 foreach ((array) $needles as $needle) {
21 if ($needle != '' && substr($haystack, 0, strlen($needle)) === (string) $needle) {
22 return true;
23 }
24 }
25
26 return false;
27 }
28
29 /**
30 * Determine if a given string ends with a given substring.
31 *
32 * @param string $haystack
33 * @param string|array $needles
34 * @return bool
35 */
36 public static function endsWith($haystack, $needles)
37 {
38 if(is_array($haystack)) {
39 $haystack = implode(' ', $haystack);
40 }
41 foreach ((array) $needles as $needle) {
42 if (substr($haystack, - strlen($needle)) === (string) $needle) {
43 return true;
44 }
45 }
46
47 return false;
48 }
49
50 /**
51 * Determine if a given string contains a given substring.
52 *
53 * @param string $haystack
54 * @param string|array $needles
55 * @return bool
56 */
57 public static function contains($haystack, $needles)
58 {
59 if(is_array($haystack)) {
60 $haystack = implode(' ', $haystack);
61 }
62
63 foreach ((array) $needles as $needle) {
64 if ($needle != '' && fluentform_mb_strpos($haystack, $needle) !== false) {
65 return true;
66 }
67 }
68
69 return false;
70 }
71
72 /**
73 * Determine if a given string does not contain a given substring.
74 *
75 * @param string $haystack
76 * @param string|array $needles
77 * @return bool
78 */
79 public static function doNotContains($haystack, $needles)
80 {
81 return !self::contains($haystack, $needles);
82 }
83 }
84