99
1010namespace MaplePHP \DTO \Format ;
1111
12+ use ErrorException ;
1213use InvalidArgumentException ;
1314use MaplePHP \DTO \MB ;
1415
@@ -29,12 +30,6 @@ public function __construct(mixed $value)
2930 parent ::__construct ((string )$ value );
3031 }
3132
32- public static function test (): self
33- {
34- $ value = ucfirst ("dwq wqdw wdqdw dqw dwq " );
35- return new self ($ value );
36- }
37-
3833 /**
3934 * Init format by adding data to modify/format/traverse
4035 * @param mixed $value
@@ -60,12 +55,12 @@ public function strVal(): string
6055 * @param integer $length total length
6156 * @param string $ending When break text add an ending (...)
6257 * @return self
63- * @throws \ ErrorException
58+ * @throws ErrorException
6459 */
6560 public function excerpt (int $ length = 40 , string $ ending = "... " ): self
6661 {
6762 $ this ->stripTags ()->entityDecode ();
68- $ this ->value = str_replace (array ( "' " , '" ' , "” " ), array ( "" , "" , "" ) , $ this ->strVal ());
63+ $ this ->value = str_replace ([ "' " , '" ' , "” " ], [ "" , "" , "" ] , $ this ->strVal ());
6964 $ mb = new MB ($ this ->value );
7065 $ strlen = $ mb ->strlen ();
7166 $ this ->value = trim ($ mb ->substr (0 , $ length ));
@@ -122,7 +117,7 @@ public function specialChars(int $flag = ENT_QUOTES): self
122117 * Can be used to sanitize SQL identifiers that should be enclosed in backticks
123118 * @return self
124119 */
125- function sanitizeIdentifiers (): self
120+ public function sanitizeIdentifiers (): self
126121 {
127122 $ this ->value = preg_replace ('/[^a-zA-Z0-9_-]/ ' , '' , $ this ->value );
128123 return $ this ;
@@ -163,7 +158,7 @@ public function clearBreaks(): self
163158 }
164159
165160 /**
166- * Clear all white spaces characters incl.:
161+ * Clear all white spaces characters incl.:
167162 * spaces, tabs, newline characters, carriage returns, and form feed characters
168163 * @return self
169164 */
@@ -281,12 +276,12 @@ public function formatSlug(): self
281276 */
282277 public function replaceSpecialChar (): self
283278 {
284- $ pattern = array ( 'é ' ,'è ' ,'ë ' ,'ê ' ,'É ' ,'È ' ,'Ë ' ,'Ê ' ,'á ' ,'à ' ,'ä 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U ' ,'y ' ,'y ' ,'Y ' ,'o ' ,'O ' ,'a ' ,'A ' ,'A ' ,'c ' ,'C ' ] ;
290285 $ this ->value = str_replace ($ pattern , $ replace , $ this ->strVal ());
291286
292287 return $ this ;
@@ -367,7 +362,7 @@ public function toggleUrlEncode(?array $find = null, ?array $replace = null): se
367362 {
368363 return $ this ->urldecode ()->rawurlencode ($ find , $ replace );
369364 }
370-
365+
371366 /**
372367 * Explode return array instance
373368 * @param non-empty-string $delimiter
@@ -448,9 +443,9 @@ public function toBool(): bool
448443 }
449444 return ($ this ->value !== "false " && strlen ($ this ->value ));
450445 }
451-
446+
452447 /**
453- * Compare value to value
448+ * Compare value to value
454449 * @param string|int|float|bool|null $compare
455450 * @return bool
456451 */
0 commit comments