vpg/titon.utility
最新稳定版本:v1.2
Composer 安装命令:
composer require vpg/titon.utility
包简介
The Titon utility package provides convenience classes for basic tasks like validation, formatting, sanitization and more.
关键字:
README 文档
README
The Titon utility package provides lightweight static classes for common tasks. All utilities extend a powerful macro system which permits the addition of new static methods at runtime.
use Titon\Utility\Inflector; Inflector::macro('upperCase', function($value) { return strtoupper($value); }); Inflector::upperCase('foo'); // FOO
Amongst the robust macro system, we can easily execute other functionality, for example.
The Converter converts one type of data to another.
Titon\Utility\Converter::toArray($xml); // Supports arrays, objects, JSON, XML, serialized
Crypt encrypts and decrypts data through the mcrypt extension.
Titon\Utility\Crypt::blowfish('foobar', $salt);
Format formats strings into common patterns.
Titon\Utility\Format::phone('1234567890', '(###) ###-####'); // (123) 456-7890
Hash mutates or accesses data in arrays.
Titon\Utility\Hash::set($array, 'foo.bar', 'baz');
Inflector rewrites strings to specific forms.
Titon\Utility\Inflector::camelCase('foo bar'); // FooBar
Number applies calculations or evaluations on numbers.
Titon\Utility\Number::bytesTo(1024); // 1KB
Path resolves file paths, namespaces, and class names.
Titon\Utility\Path::className('Vendor\Foo\Bar'); // Bar
Sanitize cleans and filters data.
Titon\Utility\Sanitize::html($data);
String modifies and analyzes strings.
Titon\Utility\String::truncate($string);
Time evaluates and compares dates and times.
Titon\Utility\Time::isTomorrow($time);
Validate validates data with defined rules and patterns.
Can be used in combination with the Validator, which provides an object oriented approach to data validation.
Titon\Utility\Validate::ext($path, ['gif', 'png', 'jpg']);
Most of the functionality found in the static classes can also be found in global functions. The list of all functions can be found in the bootstrap file within the source folder.
Features
Converter- Convert one type to anotherCrypt- Data encryption and decryptionFormat- Data formattingHash- Object and array manipulationInflector- String and grammar formattingNumber- Number manipulationPath- File system and namespace path formattingSanitize- Data cleaning and escapingString- String manipulationTime- Date and time manipulationValidate- Data validation and filteringValidator- Schema Rule Validation
Requirements
- PHP 5.3.0
- Multibyte
- SimpleXML (for Converter)
- Mcrypt (for Crypt)
- Fileinfo (for Validate)
统计信息
- 总下载量: 12.96k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: BSD-2-Clause
- 更新时间: 2015-01-01