chillerlan/php-standard-utilities

A collection of reusable multi-purpose functions for PHP libraries.

1.0.0 2024-11-12 19:02 UTC

This package is auto-updated.

Last update: 2024-12-12 19:17:12 UTC


README

A collection of reusable multi-purpose functions for PHP libraries.

PHP Version Support Packagist version License Continuous Integration CodeCov Packagist downloads

Overview

Features

This library features some common functions to reduce overall duplication and avoid certain ugly workarounds (looking at you, phpstan...).

Requirements

  • PHP 8.1+
    • extensions: json, mbstring, sodium

API

Arr

(we can't use array as class name because reasons)

Crypto

The Crypto class defines the following public constants:

pre-defined character maps for use with Crypto::randomString() as $keyspace:

  • NUMERIC: numbers 0-9
  • ASCII_LOWER: ASCII a-z
  • ASCII_UPPER: ASCII A-Z
  • ASCII_SYMBOL: ASCII printable symbols !"#$%&\'()*+,-./:;<=>?@[\]^_`{|}~
  • HEXADECIMAL: numbers 0-9 + ASCII a-f
  • ASCII_ALPHANUM: numbers 0-9 + ASCII a-z + A-Z
  • ASCII_PRINTABLE: numbers 0-9 + ASCII a-z + A-Z + printable symbols
  • ASCII_COMMON_PW: ASCII printable minus a few troublemaker symbols !#$%&()*+,-./:;<=>?@[]~_|

output and input $format for the functions Crypto::encrypt() and Crypto::decrypt(), respectively:

  • ENCRYPT_FORMAT_BINARY: raw binary
  • ENCRYPT_FORMAT_BASE64: mime base64
  • ENCRYPT_FORMAT_HEX: hexadecimal

Directory

File

Str

(see Arr)

Disclaimer

Use at your own risk!