Mark Story 06a4ef09bf Merge pull request #15097 from cakephp/disable-php8 5 years ago
..
Crypto 06d1cec3a9 Fix docblocks see links. 5 years ago
Exception 2b40e56493 Fix newlines around psr2 6 years ago
CookieCryptTrait.php 7c79b9e99c Backports from 4.next. 5 years ago
Hash.php 369b93014d Fix Hash::mergeDiff() not handling scalar values. 5 years ago
Inflector.php ae22fceb73 Backport Inflector improvements for multi words. (#14678) 5 years ago
LICENSE.txt c61ab5ee95 Use HTTPS for the cakefoundation.org URL 8 years ago
MergeVariablesTrait.php d397fbdcc8 Fix CS as per PSR-12. 6 years ago
README.md 01f4a69915 Updated links from book.cakephp.org/3.0/ to book.cakephp.org/3/ 6 years ago
Security.php 7c79b9e99c Backports from 4.next. 5 years ago
String.php 4fd1bd1a35 Add missing versions to deprecation notices. 7 years ago
Text.php f370ea00f7 Fix phpstan. 5 years ago
Xml.php a9763b9d38 Fix response deprecations 5 years ago
bootstrap.php 3a6bd75832 Use HTTPS for the opensource.org URL 8 years ago
composer.json 77a5b67b89 Set max php version for split packages 5 years ago

README.md

Total Downloads License

CakePHP Utility Classes

This library provides a range of utility classes that are used throughout the CakePHP framework

What's in the toolbox?

Hash

A Hash (as in PHP arrays) class, capable of extracting data using an intuitive DSL:

$things = [
    ['name' => 'Mark', 'age' => 15],
    ['name' => 'Susan', 'age' => 30],
    ['name' => 'Lucy', 'age' => 25]
];

$bigPeople = Hash::extract($things, '{n}[age>21].name');

// $bigPeople will contain ['Susan', 'Lucy']

Check the official Hash class documentation

Inflector

The Inflector class takes a string and can manipulate it to handle word variations such as pluralizations or camelizing.

echo Inflector::pluralize('Apple'); // echoes Apples

echo Inflector::singularize('People'); // echoes Person

Check the official Inflector class documentation

Text

The Text class includes convenience methods for creating and manipulating strings.

Text::insert(
    'My name is :name and I am :age years old.',
    ['name' => 'Bob', 'age' => '65']
);
// Returns: "My name is Bob and I am 65 years old."

$text = 'This is the song that never ends.';
$result = Text::wrap($text, 22);

// Returns
This is the song
that never ends.

Check the official Text class documentation

Security

The security library handles basic security measures such as providing methods for hashing and encrypting data.

$key = 'wt1U5MACWJFTXGenFoZoiLwQGrLgdbHA';
$result = Security::encrypt($value, $key);

Security::decrypt($result, $key);

Check the official Security class documentation

Xml

The Xml class allows you to easily transform arrays into SimpleXMLElement or DOMDocument objects and back into arrays again

$data = [
    'post' => [
        'id' => 1,
        'title' => 'Best post',
        'body' => ' ... '
    ]
];
$xml = Xml::build($data);

Check the official Xml class documentation