PluginProbe
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder / 4.3.18
Fluent Forms – Customizable Contact Forms, Survey, Quiz, & Conversational Form Builder v4.3.18
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.18, at app/Helpers/Str.php

89 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 *
13 * @return bool
14 */
15 public static function startsWith($haystack, $needles)
16 {
17 if (is_array($haystack)) {
18 $haystack = implode(' ', $haystack);
19 }
20
21 foreach ((array) $needles as $needle) {
22 if ('' != $needle && substr($haystack, 0, strlen($needle)) === (string) $needle) {
23 return true;
24 }
25 }
26
27 return false;
28 }
29
30 /**
31 * Determine if a given string ends with a given substring.
32 *
33 * @param string $haystack
34 * @param string|array $needles
35 *
36 * @return bool
37 */
38 public static function endsWith($haystack, $needles)
39 {
40 if (is_array($haystack)) {
41 $haystack = implode(' ', $haystack);
42 }
43
44 foreach ((array) $needles as $needle) {
45 if (substr($haystack, -strlen($needle)) === (string) $needle) {
46 return true;
47 }
48 }
49
50 return false;
51 }
52
53 /**
54 * Determine if a given string contains a given substring.
55 *
56 * @param string $haystack
57 * @param string|array $needles
58 *
59 * @return bool
60 */
61 public static function contains($haystack, $needles)
62 {
63 if (is_array($haystack)) {
64 $haystack = implode(' ', $haystack);
65 }
66
67 foreach ((array) $needles as $needle) {
68 if ('' != $needle && fluentform_mb_strpos($haystack, $needle) !== false) {
69 return true;
70 }
71 }
72
73 return false;
74 }
75
76 /**
77 * Determine if a given string does not contain a given substring.
78 *
79 * @param string $haystack
80 * @param string|array $needles
81 *
82 * @return bool
83 */
84 public static function doNotContains($haystack, $needles)
85 {
86 return !self::contains($haystack, $needles);
87 }
88 }
89