PluginProbe
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder / 4.3.14
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder v4.3.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 3.6.66 All 195 releases
fluentform / app / Helpers / Str.php

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

85 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
42 foreach ((array) $needles as $needle) {
43 if (substr($haystack, - strlen($needle)) === (string) $needle) {
44 return true;
45 }
46 }
47
48 return false;
49 }
50
51 /**
52 * Determine if a given string contains a given substring.
53 *
54 * @param string $haystack
55 * @param string|array $needles
56 * @return bool
57 */
58 public static function contains($haystack, $needles)
59 {
60 if (is_array($haystack)) {
61 $haystack = implode(' ', $haystack);
62 }
63
64 foreach ((array) $needles as $needle) {
65 if ($needle != '' && fluentform_mb_strpos($haystack, $needle) !== false) {
66 return true;
67 }
68 }
69
70 return false;
71 }
72
73 /**
74 * Determine if a given string does not contain a given substring.
75 *
76 * @param string $haystack
77 * @param string|array $needles
78 * @return bool
79 */
80 public static function doNotContains($haystack, $needles)
81 {
82 return !self::contains($haystack, $needles);
83 }
84 }
85