Download the PHP package makis83/helpers without Composer
On this page you can find all versions of the php package makis83/helpers. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download makis83/helpers
More information about makis83/helpers
Files in makis83/helpers
Package helpers
Short Description A collection of PHP helper classes for files, texts, images etc.
License MIT
Informations about the package helpers
Makis83 PHP Helpers
A collection of PHP helper classes for files, texts, images etc.
Installation
Use composer to install Makis83 PHP Helpers:
Requirements
- PHP 8.2 or higher
- Mbstring extension for working with text
- Tidy extension for working with HTML code
Documentation
Data Helper
isJson(string $text): bool
Check if the specified text is JSON.
jsonEncode(array $data, int $options = JSON_HEX_TAG | JSON_HEX_APOS | JSON_HEX_QUOT | JSON_HEX_AMP): string
Encode array as JSON.
jsonDecode(string $data, bool $asArray = true): mixed
Decode the JSON-sequence.
valueToArray(array|null|bool|int|float|string $value, string $delimiter = ','): array
Convert value into array.
File Helper
fileExtension(string $path): string
Get file extension from a file with the given path.
fileName(string $path, bool $withExtension = true): string
Get file name from the given path.
isAbsolutePath(string $path, bool $allowSchemes = true): bool
Check if the specified path is an absolute path.
ensureDirectory(string $path, int $mode = 0775, ?string $owner = null, ?string $group = null): true
Create a directory with the given path if it doesn't exist.
removeDirectory(string $path): void
Remove directory and all its files and subdirs recursively.
sanitizeFilename(string $fileName, string $replacement = '_'): string
Sanitizes a filename by removing characters that are problematic for filesystems.
Html Helper
isHTML(string $text): bool
Detect whether the text is an HTML code.
secure(string $data, bool $forceHtml = true, bool $purify = true, ?string $charset = null): string
Secure the specified text data.
tidy(string $html, bool $repair = true, ?string $charset = null): string
Tidy the specified HTML code.
textToHtml(string $text, ?string $charset = null): string
Convert a plain text into HTML.
textTags(string $text): array
Get HTML tags used in the text.
Text Helper
setLeadingZeroes(int $number, int $numberLength = 2): string
Prepend the integer value with leading zeroes.
classNameToId(string $class): string
Convert class name (with or without namespace) to ID.
fixSpaces(string $text): string
Fixes issues with spaces, NBSPs etc.
Tests
Run the tests using PHPUnit and PHPStan:
or
License
This project is licensed under the MIT License.
All versions of helpers with dependencies
ext-mbstring Version *
ext-tidy Version *
ezyang/htmlpurifier Version dev-master
thecodingmachine/safe Version ^3.3