syntatis / utils
Handy functions for PHP
Installs: 17 458
Dependents: 1
Suggesters: 0
Security: 0
Stars: 6
Watchers: 0
Forks: 0
Open Issues: 0
Requires
- php: >=7.4
- jawira/case-converter: ^3.5
Requires (Dev)
- composer/installers: ^2.3
- dealerdirect/phpcodesniffer-composer-installer: ^1.0
- phpcompatibility/php-compatibility: ^9.3
- phpstan/extension-installer: ^1.4
- phpstan/phpstan: ^1.12
- phpstan/phpstan-deprecation-rules: ^1.2
- phpstan/phpstan-phpunit: ^1.4
- phpstan/phpstan-strict-rules: ^1.6
- phpunit/phpunit: ^9.6
- squizlabs/php_codesniffer: ^3.10
- symfony/var-dumper: >=5.4.40
- syntatis/coding-standard: ^1.4
README
The syntatis/utils
package provides a variety of utility functions to simplify common tasks in PHP, including validation, case conversion, and inflection.
Installation
You can install the package via Composer:
composer require syntatis/utils
Usage
Validator
This package includes several functions for validating values, such as checking if a value is an email, URL, or whether it is blank.
Examples
use function Syntatis\Utils\Val; // Check if a value is blank or empty Val::isBlank(''); // true Val::isBlank(' '); // true Val::isBlank('foo '); // false // Check if a value is a valid email address Val::isEmail('example@example.com'); // true Val::isEmail('invalid-email'); // false
Strings
This package includes several functions to handle strings, such as converting a string to camel case, makes a word plural, or checking if a string starts with a specific substring.
Examples
use function Syntatis\Utils\Str; // Convert a string to camel case Str::toCamelCase('foo_bar'); // fooBar // Check if a string starts with a specific substring Str::startsWith('Hello, World!', 'Hello'); // true
Arrays
This package includes several functions to handle arrays. For example, checking if an array is a list or associative array, or checking if all elements in an array are unique.