1 | <?php |
||
11 | class Stringy { |
||
12 | |||
13 | private $text; |
||
14 | |||
15 | public function __construct($string) |
||
23 | |||
24 | /** |
||
25 | * @return string |
||
26 | */ |
||
27 | public function string() |
||
31 | |||
32 | /** |
||
33 | * @param int $chars |
||
34 | * @param string $appendWith |
||
35 | * @return $this |
||
36 | */ |
||
37 | public function truncate($chars = 50, $appendWith = "...") |
||
46 | |||
47 | /** |
||
48 | * @return int |
||
49 | */ |
||
50 | public function length() |
||
54 | |||
55 | /** |
||
56 | * @param $substring |
||
57 | * @return bool |
||
58 | */ |
||
59 | public function contains($substring) |
||
63 | |||
64 | /** |
||
65 | * @param $substring |
||
66 | * @return bool |
||
67 | */ |
||
68 | public function startsWith($substring) |
||
72 | |||
73 | /** |
||
74 | * @param $substring |
||
75 | * @return bool |
||
76 | */ |
||
77 | public function endsWith($substring) |
||
81 | |||
82 | /** |
||
83 | * @param $string |
||
84 | * @param string $separator |
||
85 | * @return $this |
||
86 | */ |
||
87 | public function append($string, $separator = " ") |
||
92 | |||
93 | /** |
||
94 | * @return $this |
||
95 | */ |
||
96 | public function reverse() |
||
101 | |||
102 | /** |
||
103 | * @return $this |
||
104 | */ |
||
105 | public function uppercase() |
||
110 | |||
111 | /** |
||
112 | * @return $this |
||
113 | */ |
||
114 | public function lowercase() |
||
119 | |||
120 | /** |
||
121 | * @return $this |
||
122 | */ |
||
123 | public function lowercaseFirst() |
||
128 | |||
129 | /** |
||
130 | * @return $this |
||
131 | */ |
||
132 | public function uppercaseFirst() |
||
137 | |||
138 | /** |
||
139 | * @return $this |
||
140 | */ |
||
141 | public function titleCase() |
||
146 | |||
147 | /** |
||
148 | * @return $this |
||
149 | */ |
||
150 | public function sentenceCase() |
||
163 | |||
164 | /** |
||
165 | * @param $delimiter |
||
166 | * @return array |
||
167 | */ |
||
168 | public function toArray($delimiter = null) |
||
172 | |||
173 | /** |
||
174 | * @param callable $function |
||
175 | * @return $this |
||
176 | */ |
||
177 | public function apply(callable $function) |
||
191 | } |