Special methods
This group of methods is designed to perform operations with data without interacting with other properties and methods of classes. These functions are static and located in the Service class.
- cutText($text, $length[, $end]) - trim text to the required number of characters while preserving the last word. In the optional parameter you can pass a string value that will be added to the trimmed text if the original text is longer than the value of $length
- randomString($length) - returns a random string in Latin in lowercase
- strongRandomString($length) - returns a random string in Latin with upper and lowercase characters
- addFileRoot($path) - adds the root of the file system to the file, $path must start from the root of the project, without the leading slash, usually userfiles/models/ or userfiles/images/
- removeFileRoot($path) - removes the root of the file system, leaving the path to the file from the root of the project without the leading slash
- getExtension($file) - returns the file extension without the dot
- removeExtension($file) - returns the file path value without the extension
- setFullHttpPath($path) - adds the current domain from the .env file to the link
- translateFileName($file_name) - translates the file name into Latin transliteration
- makeHash($string, $cost = 10) - returns the string hash, the password_hash() function
- checkHash($string, $hash) - checks the string hash
Examples of using Service class methods
echo Service::cutText($text, 200, '...');
echo Service::randomString(7);
echo Service::strongRandomString(20);
echo Service::setFullHttpPath('/news/25');
echo Service::makeHash('hello');
Previous section
Sending email