kusabi/native

A library that extends PHP's native functionality

0.0.3 2020-11-28 10:11 UTC

This package is auto-updated.

Last update: 2024-04-28 18:13:41 UTC


README

Tests codecov Licence Badge Release Badge Tag Badge Issues Badge Code Size

A library that extends PHP's native functionality

Compatibility and dependencies

This library is compatible with PHP version 5.6, 7.0, 7.1, 7.2, 7.3, 7.4, 8.0 and 8.1.

This library has no dependencies.

Installation

Installation is simple using composer.

composer require kusabi/native

Or simply add it to your composer.json file

{
    "require": {
        "kusabi/native": "^1.0"
    }
}

Array functions

This library adds a number of array functions to extend PHP's native functionality

Below you can find links to the documentation for the new features.

Function Description
array_at Get the nth value from an array
array_deflate Flattens a nested array into a single level array
array_except Return a subset of the array by passing in an array of keys to discard
array_exists Checks if the given key or index exists in the array using dot notation for nested arrays
array_get Returns a value from the array, using dot notation for nested sets
array_inflate Expands a flattened array back into a nested array
array_key_at Get the nth key from an array
array_only Return a subset of the array by passing in an array of keys to keep
array_pull Return and remove a key in the array using dot notation for nested arrays
array_random Picks one or more random entries out of an array, and returns the value (or values) of the random entries
array_set Set a key in the array using dot notation for nested arrays
array_unset Remove a key in the array using dot notation for nested arrays

Class functions

This library adds a number of class functions to extend PHP's native functionality

Below you can find links to the documentation for the new features.

Function Description
class_uses_recursive Get a deep list of all the traits a class uses
class_uses_trait Determine if a class or object uses a trait

String functions

This library adds a number of strings functions to extend PHP's native functionality

Below you can find links to the documentation for the new features.

Function Description
str_case_camel Converts a string to camelCase
str_case_kebab Converts a string to kebab-case
str_case_pascal Converts a string to PascalCase
str_case_sentence Converts a string to Sentence case
str_case_snake Converts a string to snake_case
str_case_title Converts a string to Title Case
str_cipher_caesar Transform a string by shifting each letter up or down the alphabet
str_cipher_caesar_reverse Reverse the effects of str_cipher_caesar
str_cipher_mono_alphabetic Transform a string by mapping each letter to another alphabet
str_contains Determine if a string contains another string
str_ends_with Determine if a string ends with another string
str_random Creates a string of random characters
str_slug Converts a string to a slug
str_starts_with Determine if a string starts with another string