String utilities

PHP comes with a large collection of string functions. The SMStringUtilities class extends the collection of string functions with functionality not covered by PHP.


SMStringUtilities class

Function Return type Description
StartsWith($str:string, $search:string) Boolean Returns True if the $str starts with the value of $search, otherwise False.
EndsWith($str:string, $search:string) Boolean Returns True if the $str ends with the value of $search, otherwise False.
SplitCaseInsensitive($str:string, $splitter:string) String[] Split $str using $splitter. If the splitter is a character (or multiple), $str will be split by both the lower case and upper case character(s).


Stop Watch

The stop watch is another useful utility that lets the developer measure time usage. This is commonly used when working with performance optimisation.


SMStopWatch class

Function Return type Description
__construct()
Create instance of stop watch. The stop watch will automatically start measuring time when instance is created.
Start()
Start or re-start the stop watch.
Stop()
Stop the stop watch.
GetSeconds() Float Returns time usage as float. The stop watch will be stopped, if not already stopped.