Download the PHP package northwestern-sysdev/lodash-php without Composer

On this page you can find all versions of the php package northwestern-sysdev/lodash-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package lodash-php

Lodash-PHP

Lodash-PHP is a port of the Lodash JS library to PHP. It is a set of easy to use utility functions for everyday PHP projects.

Lodash-PHP tries to mimick lodash.js as close as possible

🚨🚨🚨 This is a fork since upstream hasn't been updated in a while, and some PHP 8 compatibility issues have emerged!

Installation

Install Lodash-PHP through composer:

Usage

Each method in Lodash-PHP is a separate function that can be imported and used on it's own.

Lodash-PHP also comes with a global _ class that can be used globally.

Methods

Array

chunk

Creates an array of elements split into groups the length of size. If array can't be split evenly, the final chunk will be the remaining elements.

Arguments:

@param array $array array The array to process.

@param int $number [size=1] The length of each chunk

Return:

@return array Returns the new array of chunks.

Example:

compact

Creates an array with all falsey values removed. The values false, null, 0, "", undefined, and NaN are falsey.

Arguments:

@param array $array The array to compact.

Return:

@return array Returns the new array of filtered values.

Example:

concat

Creates a new array concatenating array with any additional arrays and/or values.

Arguments:

@param array $array The array to concatenate.

@param array<int, mixed> $values The values to concatenate.

Return:

@return array Returns the new concatenated array.

Example:

difference

Creates an array of array values not included in the other given arrays using SameValueZero for equality comparisons. The order and references of result values are determined by the first array.

Note: Unlike pullAll, this method returns a new array.

Arguments:

@param array $array The array to inspect.

@param array ...$values The values to exclude.

Return:

@return array Returns the new array of filtered values.

Example:

differenceBy

This method is like difference except that it accepts iteratee which is invoked for each element of array and values to generate the criterion by which they're compared. The order and references of result values are determined by the first array. The iteratee is invoked with one argument: (value).

Note: Unlike pullAllBy, this method returns a new array.

Arguments:

@param array $array The array to inspect.

@param array<int, mixed> ...$values The values to exclude.

@param callable $iteratee The iteratee invoked per element.

Return:

@return array Returns the new array of filtered values.

Example:

differenceWith

This method is like difference except that it accepts comparator which is invoked to compare elements of array to values. The order and references of result values are determined by the first array. The comparator is invoked with two arguments: (arrVal, othVal).

Note: Unlike pullAllWith, this method returns a new array.

Arguments:

@param array<int, mixed> $array The array to inspect.

@param array ...$values The values to exclude.

@param callable $comparator The comparator invoked per element.

Return:

@return array Returns the new array of filtered values.

Example:

drop

Creates a slice of array with n elements dropped from the beginning.

NOTE: This function will reorder and reset the array indices

Arguments:

@param array $array The array to query.

@param int $n The number of elements to drop.

Return:

@return array the slice of array.

Example:

dropRight

Creates a slice of array with n elements dropped from the end. NOTE: This function will reorder and reset the array indices

Arguments:

@param array $array The array to query.

@param int $n The number of elements to drop.

Return:

@return array the slice of array.

Example:

dropRightWhile

Creates a slice of array excluding elements dropped from the end. Elements are dropped until predicate returns falsey. The predicate is invoked with three arguments: (value, index, array).

Arguments:

@param array $array The array to query.

@param callable $predicate The function invoked per iteration.

Return:

@return array the slice of array.

Example:

dropWhile

Creates a slice of array excluding elements dropped from the beginning. Elements are dropped until predicate returns falsey. The predicate is invoked with three arguments: (value, index, array).

Arguments:

@param array $array The array to query.

@param callable $predicate The function invoked per iteration.

Return:

@return array the slice of array.

Example:

every

Checks if predicate returns truthy for all elements of array. Iteration is stopped once predicate returns falsey. The predicate is invoked with three arguments: (value, index, array).

Note: This method returns true for empty arrays because everything is true of elements of empty arrays.

Arguments:

@param iterable $collection The array to iterate over.

@param callable $predicate The function invoked per iteration.

Return:

@return bool true if all elements pass the predicate check, else false.

Example:

findIndex

This method is like find except that it returns the index of the first element predicate returns truthy for instead of the element itself.

Arguments:

@param array $array The array to inspect.

@param callable $predicate The function invoked per iteration.

@param int $fromIndex The index to search from.

Return:

@return int the index of the found element, else -1.

Example:

findLastIndex

This method is like findIndex except that it iterates over elements of collection from right to left.

Arguments:

@param array $array The array to inspect.

@param mixed $predicate The function invoked per iteration.

@param int $fromIndex The index to search from.

Return:

@return int the index of the found element, else -1.

Example:

flatten

Flattens array a single level deep.

Arguments:

@param array $array The array to flatten.

Return:

@return array the new flattened array.

Example:

flattenDeep

Recursively flattens array.

Arguments:

@param array $array The array to flatten.

Return:

@return array Returns the new flattened array.

Example:

flattenDepth

Recursively flatten array up to depth times.

Arguments:

@param array $array The array to flatten.

@param int $depth The maximum recursion depth.

Return:

@return array the new flattened array.

Example:

fromPairs

The inverse of toPairs, this method returns an object composed from key-value pairs.

Arguments:

@param array $pairs The key-value pairs.

Return:

@return \stdClass the new object.

Example:

head

Gets the first element of array.

Arguments:

@param array $array The array to query.

Return:

@return mixed Returns the first element of array.

Example:

indexOf

Gets the index at which the first occurrence of value is found in array using SameValueZero for equality comparisons. If fromIndex is negative, it's used as the offset from the end of array.

Arguments:

@param array $array The array to inspect.

@param mixed $value The value to search for.

@param int $fromIndex The index to search from.

Return:

@return int the index of the matched value, else -1.

Example:

initial

Gets all but the last element of array.

Arguments:

@param array $array The array to query.

Return:

@return array the slice of array.

Example:

intersection

Creates an array of unique values that are included in all given arrays using SameValueZero for equality comparisons. The order and references of result values are determined by the first array.

Arguments:

@param array ...$arrays

Return:

@return array the new array of intersecting values.

Example:

intersectionBy

This method is like intersection except that it accepts iteratee which is invoked for each element of each arrays to generate the criterion by which they're compared. The order and references of result values are determined by the first array. The iteratee is invoked with one argument: (value).

Arguments:

@param array<int, mixed> ...$arrays

@param callable $iteratee The iteratee invoked per element.

Return:

@return array the new array of intersecting values.

Example:

intersectionWith

This method is like intersection except that it accepts comparator which is invoked to compare elements of arrays. The order and references of result values are determined by the first array. The comparator is invoked with two arguments: (arrVal, othVal).

Arguments:

@param array ...$arrays

@param callable $comparator The comparator invoked per element.

Return:

@return array the new array of intersecting values.

Example:

last

Gets the last element of array.

Arguments:

@param array $array The array to query.

Return:

@return mixed Returns the last element of array.

Example:

lastIndexOf

This method is like indexOf except that it iterates over elements of array from right to left.

Arguments:

@param array $array The array to inspect.

@param mixed $value The value to search for.

@param int $fromIndex The index to search from.

Return:

@return int the index of the matched value, else -1.

Example:

nth

Gets the element at index n of array. If n is negative, the nth element from the end is returned.

Arguments:

@param array $array The array to query.

@param int $n The index of the element to return.

Return:

@return mixed Returns the nth element of array.

Example:

pull

Removes all given values from array using SameValueZero for equality comparisons.

Note: Unlike without, this method mutates array. Use remove to remove elements from an array by predicate.

Arguments:

@param array $array The array to modify.

@param array<int, string> $values The values to remove.

Return:

@return array

Example:

pullAll

This method is like pull except that it accepts an array of values to remove.

Note: Unlike difference, this method mutates array.

Arguments:

@param array $array The array to modify.

@param array $values The values to remove.

Return:

@return array array.

Example:

pullAllBy

This method is like pullAll except that it accepts iteratee which is invoked for each element of array and values to generate the criterion by which they're compared. The iteratee is invoked with one argument: (value).

Note: Unlike differenceBy, this method mutates array.

Arguments:

@param array $array The array to modify.

@param array $values The values to remove.

@param callable $iteratee The iteratee invoked per element.

Return:

@return array array.

Example:

pullAllWith

This method is like pullAll except that it accepts comparator which is invoked to compare elements of array to values. The comparator is invoked with two arguments: (arrVal, othVal).

Note: Unlike differenceWith, this method mutates array.

Arguments:

@param array $array The array to modify.

@param array $values The values to remove.

@param callable $comparator The comparator invoked per element.

Return:

@return array array.

Example:

pullAt

Removes elements from array corresponding to indexes and returns an array of removed elements.

Note: Unlike at, this method mutates array.

Arguments:

@param array $array The array to modify.

@param (int | int[]) $indexes The indexes of elements to remove.

Return:

@return array the new array of removed elements.

Example:

remove

Removes all elements from array that predicate returns truthy for and returns an array of the removed elements. The predicate is invoked with three arguments: (value, index, array).

Note: Unlike filter, this method mutates array. Use pull to pull elements from an array by value.

Arguments:

@param array $array The array to modify.

@param callable $predicate The function invoked per iteration.

Return:

@return array the new array of removed elements.

Example:

sample

Gets a random element from array.

Arguments:

@param array $array The array to sample.

Return:

@return mixed Returns the random element.

Example:

sampleSize

Gets n random elements at unique keys from array up to the size of array.

Arguments:

@param array $array The array to sample.

@param int $n The number of elements to sample.

Return:

@return array the random elements.

Example:

shuffle

Creates an array of shuffled values

Arguments:

@param array $array The array to shuffle.

Return:

@return array the new shuffled array.

Example:

slice

Creates a slice of array from start up to, but not including, end.

Arguments:

@param array $array The array to slice.

@param int $start The start position.

@param int $end The end position.

Return:

@return array the slice of array.

tail

Gets all but the first element of array.

Arguments:

@param array $array The array to query.

Return:

@return array the slice of array.

Example:

take

Creates a slice of array with n elements taken from the beginning.

Arguments:

@param array $array The array to query.

@param int $n The number of elements to take.

Return:

@return array the slice of array.

Example:

takeRight

Creates a slice of array with n elements taken from the end.

Arguments:

@param array $array The array to query.

@param int $n The number of elements to take.

Return:

@return array the slice of array.

Example:

takeRightWhile

Creates a slice of array with elements taken from the end. Elements are taken until predicate returns falsey. The predicate is invoked with three arguments: (value, index, array).

Arguments:

@param array $array The array to query.

@param callable $predicate The function invoked per iteration.

Return:

@return array the slice of array.

Example:

takeWhile

Creates a slice of array with elements taken from the beginning. Elements are taken until predicate returns falsey. The predicate is invoked with three arguments: (value, index, array).

Arguments:

@param array $array The array to query.

@param mixed $predicate The function invoked per iteration.

Return:

@return array the slice of array.

Example:

union

Creates an array of unique values, in order, from all given arrays using SameValueZero for equality comparisons.

Arguments:

@param array ...$arrays The arrays to inspect.

Return:

@return array the new array of combined values.

Example:

unionBy

This method is like union except that it accepts iteratee which is invoked for each element of each arrays to generate the criterion by which uniqueness is computed. Result values are chosen from the first array in which the value occurs. The iteratee is invoked with one argument: (value).

Arguments:

@param array<int, mixed> ...$arrays The arrays to inspect.

@param callable $iteratee The iteratee invoked per element.

Return:

@return array the new array of combined values.

Example:

unionWith

This method is like union except that it accepts comparator which is invoked to compare elements of arrays. Result values are chosen from the first array in which the value occurs. The comparator is invoked with two arguments: (arrVal, othVal).

Arguments:

@param array<int, mixed> ...$arrays The arrays to inspect.

@param callable $comparator The comparator invoked per element.

Return:

@return array the new array of combined values.

Example:

uniq

Creates a duplicate-free version of an array, using SameValueZero for equality comparisons, in which only the first occurrence of each element is kept. The order of result values is determined by the order they occur in the array.

Arguments:

@param array $array The array to inspect.

Return:

@return array the new duplicate free array.

Example:

uniqBy

This method is like uniq except that it accepts iteratee which is invoked for each element in array to generate the criterion by which uniqueness is computed. The order of result values is determined by the order they occur in the array. The iteratee is invoked with one argument: (value).

Arguments:

@param array $array The array to inspect.

@param mixed $iteratee The iteratee invoked per element.

Return:

@return array the new duplicate free array.

Example:

uniqWith

This method is like uniq except that it accepts comparator which is invoked to compare elements of array. The order of result values is determined by the order they occur in the array.The comparator is invoked with two arguments: (arrVal, othVal).

Arguments:

@param array $array The array to inspect.

@param callable $comparator The comparator invoked per element.

Return:

@return array the new duplicate free array.

Example:

unzip

This method is like zip except that it accepts an array of grouped elements and creates an array regrouping the elements to their pre-zip configuration.

Arguments:

@param array $array The array of grouped elements to process.

Return:

@return array the new array of regrouped elements.

Example:

unzipWith

This method is like unzip except that it accepts iteratee to specify how regrouped values should be combined. The iteratee is invoked with the elements of each group: (...group).

Arguments:

@param array $array The array of grouped elements to process.

@param (callable | null) $iteratee The function to combine regrouped values.

Return:

@return array the new array of regrouped elements.

Example:

without

Creates an array excluding all given values using SameValueZero for equality comparisons.

Note: Unlike pull, this method returns a new array.

Arguments:

@param array $array The array to inspect.

@param array<int, mixed> $values The values to exclude.

Return:

@return array the new array of filtered values.

Example:

zip

Creates an array of grouped elements, the first of which contains the first elements of the given arrays, the second of which contains the second elements of the given arrays, and so on.

Arguments:

@param array ...$arrays The arrays to process.

Return:

@return array the new array of grouped elements.

Example:

zipObject

This method is like fromPairs except that it accepts two arrays, one of property identifiers and one of corresponding values.

Arguments:

@param array $props The property identifiers.

@param array $values The property values.

Return:

@return object the new object.

Example:

zipObjectDeep

This method is like zipObject except that it supports property paths.

Arguments:

@param array $props The property identifiers.

@param array $values The property values.

Return:

@return \stdClass the new object.

Example:

zipWith

This method is like zip except that it accepts iteratee to specify how grouped values should be combined. The iteratee is invoked with the elements of each group: (...group).

Arguments:

@param array<int, (array | callable)> ...$arrays The arrays to process.

@param callable $iteratee The function to combine grouped values.

Return:

@return array the new array of grouped elements.

Example:

Collection

countBy

Creates an array composed of keys generated from the results of running each element of collection through iteratee. The corresponding value of each key is the number of times the key was returned by iteratee. The iteratee is invoked with one argument: (value).

Arguments:

@param iterable $collection The collection to iterate over.

@param callable $iteratee The iteratee to transform keys.

Return:

@return array Returns the composed aggregate object.

Example:

each

Iterates over elements of collection and invokes iteratee for each element. The iteratee is invoked with three arguments: (value, index|key, collection). Iteratee functions may exit iteration early by explicitly returning false.

Note: As with other "Collections" methods, objects with a "length" property are iterated like arrays. To avoid this behavior use forIn or forOwn for object iteration.

Arguments:

@param (array | iterable | object) $collection The collection to iterate over.

@param callable $iteratee The function invoked per iteration.

Return:

@return (array | object) Returns collection.

Example:

eachRight

This method is like each except that it iterates over elements of collection from right to left.

Arguments:

@param (array | iterable | object) $collection The collection to iterate over.

@param callable $iteratee The function invoked per iteration.

Return:

@return (array | object) Returns collection.

Example:

filter

Iterates over elements of array, returning an array of all elements predicate returns truthy for. The predicate is invoked with three arguments: (value, index, array).

Note: Unlike remove, this method returns a new array.

Arguments:

@param iterable $array The array to iterate over.

@param callable $predicate The function invoked per iteration.

Return:

@return array the new filtered array.

Example:

find

Iterates over elements of collection, returning the first element predicate returns truthy for. The predicate is invoked with three arguments: (value, index|key, collection).

Arguments:

@param iterable $collection The collection to inspect.

@param callable $predicate The function invoked per iteration.

@param int $fromIndex The index to search from.

Return:

@return mixed Returns the matched element, else null.

Example:

findLast

This method is like find except that it iterates over elements of collection from right to left.

Arguments:

@param iterable $collection The collection to inspect.

@param callable $predicate The function invoked per iteration.

@param int $fromIndex The index to search from.

Return:

@return mixed Returns the matched element, else undefined.

Example:

flatMap

Creates a flattened array of values by running each element in collection through iteratee and flattening the mapped results. The iteratee is invoked with three arguments: (value, index|key, collection).

Arguments:

@param iterable $collection The collection to iterate over.

@param callable $iteratee The function invoked per iteration.

Return:

@return array the new flattened array.

Example:

flatMapDeep

This method is like flatMap except that it recursively flattens the mapped results.

Arguments:

@param iterable $collection The collection to iterate over.

@param callable $iteratee The function invoked per iteration.

Return:

@return array Returns the new flattened array.

Example:

flatMapDepth

This method is like flatMap except that it recursively flattens the mapped results up to depth times.

Arguments:

@param iterable $collection The collection to iterate over.

@param callable $iteratee The function invoked per iteration.

@param int $depth The maximum recursion depth.

Return:

@return array the new flattened array.

Example:

groupBy

Creates an array composed of keys generated from the results of running each element of collection through iteratee. The order of grouped values is determined by the order they occur in collection. The corresponding value of each key is an array of elements responsible for generating the key. The iteratee is invoked with one argument: (value).

Arguments:

@param iterable $collection The collection to iterate over.

@param callable $iteratee The iteratee to transform keys.

Return:

@return array Returns the composed aggregate object.

Example:

invokeMap

Invokes the method at path of each element in collection, returning an array of the results of each invoked method. Any additional arguments are provided to each invoked method. If path is a function, it's invoked for, and this bound to, each element in collection.

Arguments:

@param iterable $collection The collection to iterate over.

@param (array | callable | string) $path The path of the method to invoke or the function invoked per iteration.

@param array $args The arguments to invoke each method with.

Return:

@return array the array of results.

Example:

keyBy

Creates an object composed of keys generated from the results of running each element of collection through iteratee. The corresponding value of each key is the last element responsible for generating the key. The iteratee is invoked with one argument: (value).

Arguments:

@param iterable $collection The collection to iterate over.

@param callable $iteratee The iteratee to transform keys.

Return:

@return array the composed aggregate object.

Example:

map

Creates an array of values by running each element in collection through iteratee. The iteratee is invoked with three arguments: (value, index|key, collection).

Many lodash-php methods are guarded to work as iteratees for methods like _::every, _::filter, _::map, _::mapValues, _::reject, and _::some.

The guarded methods are: ary, chunk, curry, curryRight, drop, dropRight, every, fill, invert, parseInt, random, range, rangeRight, repeat, sampleSize, slice, some, sortBy, split, take, takeRight, template, trim, trimEnd, trimStart, and words

Arguments:

@param (array | object) $collection The collection to iterate over.

@param (callable | string | array) $iteratee The function invoked per iteration.

Return:

@return array Returns the new mapped array.

Example:

orderBy

This method is like sortBy except that it allows specifying the sort orders of the iteratees to sort by. If orders is unspecified, all values are sorted in ascending order. Otherwise, specify an order of "desc" for descending or "asc" for ascending sort order of corresponding values.

Arguments:

@param (iterable | null) $collection The collection to iterate over.

@param (array[] | callable[] | string[]) $iteratee The iteratee(s) to sort by.

@param string[] $orders The sort orders of iteratees.

Return:

@return array the new sorted array.

Example:

partition

Creates an array of elements split into two groups, the first of which contains elements predicate returns truthy for, the second of which contains elements predicate returns falsey for. The predicate is invoked with one argument: (value).

Arguments:

@param iterable $collection The collection to iterate over.

@param callable $predicate The function invoked per iteration.

Return:

@return array the array of grouped elements.

Example:

reduce

Reduces collection to a value which is the accumulated result of running each element in collection thru iteratee, where each successive invocation is supplied the return value of the previous. If accumulator is not given, the first element of collection is used as the initial value. The iteratee is invoked with four arguments: (accumulator, value, index|key, collection).

Many lodash methods are guarded to work as iteratees for methods like reduce, reduceRight, and transform.

The guarded methods are: assign, defaults, defaultsDeep, includes, merge, orderBy, and sortBy

Arguments:

@param iterable $collection The collection to iterate over.

@param mixed $iteratee The function invoked per iteration.

@param mixed $accumulator The initial value.

Return:

@return mixed Returns the accumulated value.

Example:

reduceRight

This method is like reduce except that it iterates over elements of collection from right to left.

Arguments:

@param iterable $collection The collection to iterate over.

@param mixed $iteratee The function invoked per iteration.

@param mixed $accumulator The initial value.

Return:

@return mixed Returns the accumulated value.

Example:

reject

The opposite of filter this method returns the elements of collection that predicate does not return truthy for.

Arguments:

@param iterable $collection The collection to iterate over.

@param callable $predicate The function invoked per iteration.

Return:

@return array the new filtered array.

Example:

size

Gets the size of collection by returning its length for array values or the number of public properties for objects.

Arguments:

@param (array | object | string) $collection The collection to inspect.

Return:

@return int Returns the collection size.

Example:

some

Checks if predicate returns truthy for any element of collection. Iteration is stopped once predicate returns truthy. The predicate is invoked with three arguments: (value, index|key, collection).

Arguments:

@param iterable $collection The collection to iterate over.

@param (callable | string | array) $predicate The function invoked per iteration.

Return:

@return boolean Returns true if any element passes the predicate check, else false.

Example:

sortBy

Creates an array of elements, sorted in ascending order by the results of running each element in a collection through each iteratee. This method performs a stable sort, that is, it preserves the original sort order of equal elements. The iteratees are invoked with one argument: (value).

Arguments:

@param (array | object | null) $collection The collection to iterate over.

@param (callable | callable[]) $iteratees The iteratees to sort by.

Return:

@return array Returns the new sorted array.

Example:

Date

now

Gets the timestamp of the number of milliseconds that have elapsed since the Unix epoch (1 January 1970 00:00:00 UTC).

Arguments:

Return:

@return int Returns the timestamp.

Example:

Function

after

The opposite of before; this method creates a function that invokes func once it's called n or more times.

Arguments:

@param int $n The number of calls before func is invoked.

@param Callable $func The function to restrict.

Return:

@return Callable Returns the new restricted function.

Example:

ary

Creates a function that invokes func, with up to n arguments, ignoring any additional arguments.

Arguments:

@param callable $func The function to cap arguments for.

@param int $n The arity cap.

Return:

@return Callable Returns the new capped function.

Example:

before

Creates a function that invokes func, with the arguments of the created function, while it's called less than n times. Subsequent calls to the created function return the result of the last func invocation.

Arguments:

@param int $n The number of calls at which func is no longer invoked.

@param callable $func The function to restrict.

Return:

@return callable Returns the new restricted function.

Example:

bind

Creates a function that invokes func with the this binding of object and partials prepended to the arguments it receives.

Arguments:

@param callable $function The function to bind.

@param (object | mixed) $object The object binding of func.

@param array<int, mixed> $partials The arguments to be partially applied.

Return:

@return callable Returns the new bound function.

Example:

bindKey

Creates a function that invokes the method $function of $object with $partials prepended to the arguments it receives.

This method differs from bind by allowing bound functions to reference methods that may be redefined or don't yet exist

Arguments:

@param object $object The object to invoke the method on.

@param string $function The name of the method.

@param array<int, mixed> $partials The arguments to be partially applied.

Return:

@return callable Returns the new bound function.

Example:

curry

Creates a function that accepts arguments of func and either invokes func returning its result, if at least arity number of arguments have been provided, or returns a function that accepts the remaining func arguments, and so on. The arity of func may be specified if func.length is not sufficient.

The _.curry.placeholder value, which defaults to _ in monolithic builds, may be used as a placeholder for provided arguments.

Note: This method doesn't set the "length" property of curried functions.

Arguments:

@param callable $func The function to curry.

@param (int | null) $arity The arity of func.

Return:

@return callable Returns the new curried function.

Example:

delay

Invokes func after wait milliseconds. Any additional arguments are provided to func when it's invoked.

Arguments:

@param callable $func The function to delay.

@param int $wait The number of milliseconds to delay invocation.

@param array<int, mixed> $args

Return:

@return int the timer id.

Example:

flip

Creates a function that invokes func with arguments reversed.

Arguments:

@param callable $func The function to flip arguments for.

Return:

@return callable Returns the new flipped function.

Example:

memoize

Creates a function that memoizes the result of func. If resolver is provided, it determines the cache key for storing the result based on the arguments provided to the memoized function. By default, the first argument provided to the memoized function is used as the map cache key

Note: The cache is exposed as the cache property on the memoized function. Its creation may be customized by replacing the _.memoize.Cache constructor with one whose instances implement the Map method interface of clear, delete, get, has, and set.

Arguments:

@param callable $func The function to have its output memoized.

@param (callable | null) $resolver The function to resolve the cache key.

Return:

@return callable Returns the new memoized function.

Example:

negate

Creates a function that negates the result of the predicate func

Arguments:

@param callable $predicate The predicate to negate.

Return:

@return callable Returns the new negated function.

Example:

once

Creates a function that is restricted to invoking func once. Repeat calls to the function return the value of the first invocation. The func is invoked with the arguments of the created function.

Arguments:

@param callable $func The function to restrict.

Return:

@return callable the new restricted function.

Example:

overArgs

Creates a function that invokes func with its arguments transformed.

Arguments:

@param callable $func The function to wrap.

@param callable[] $transforms The argument transforms.

Return:

@return callable the new function.

Example:

partial

Creates a function that invokes func with partials prepended to the arguments it receives.

Arguments:

@param callable $func The function to partially apply arguments to.

@param array<int, mixed> $partials The arguments to be partially applied.

Return:

@return callable Returns the new partially applied function.

Example:

rest

Creates a function that invokes func with the this binding of the created function and arguments from start and beyond provided as an array.

Arguments:

@param callable $func The function to apply a rest parameter to.

@param (int | null) $start The start position of the rest parameter.

Return:

@return callable Returns the new function.

Example:

spread

Creates a function that invokes func with the this binding of the create function and an array of arguments much like Function#apply.

Note: This method is based on the spread operator.

Arguments:

@param callable $func The function to spread arguments over.

@param int $start The start position of the spread.

Return:

@return callable Returns the new function.

Example:

unary

Creates a function that accepts up to one argument, ignoring any additional arguments.

Arguments:

@param callable $func The function to cap arguments for.

Return:

@return callable the new capped function.

Example:

wrap

Creates a function that provides value to wrapper as its first argument. Any additional arguments provided to the function are appended to those provided to the wrapper.

Arguments:

@param mixed $value The value to wrap.

@param callable $wrapper The wrapper function.

Return:

@return callable the new function.

Example:

Lang

eq

Performs a comparison between two values to determine if they are equivalent.

Arguments:

@param mixed $value The value to compare.

@param mixed $other The other value to compare.

Return:

@return boolean Returns true if the values are equivalent, else false.

Example:

isEqual

Performs a deep comparison between two values to determine if they are equivalent.

Note: This method supports comparing arrays, booleans, DateTime objects, exception objects, SPLObjectStorage, numbers, strings, typed arrays, resources, DOM Nodes. objects are compared by their own, not inherited, enumerable properties.

Arguments:

@param mixed $value The value to compare.

@param mixed $other The other value to compare.

Return:

@return bool Returns true if the values are equivalent, else false.

Example:

isError

Checks if value is an \Exception, \ParseError, \Error, \Throwable, \SoapFault, \DOMException, \PDOException`, object.

Arguments:

@param mixed $value The value to check.

Return:

@return boolean Returns true if value is an error object, else false.

Example:

Math

add

Adds two numbers.

Arguments:

@param (int | float | string) $augend The first number in an addition.

@param (int | float | string) $addend The second number in an addition.

Return:

@return (int | float) Returns the total.

Example:

max

Computes the maximum value of array. If array is empty or falsey, null is returned.

Arguments:

@param (array | null) $array The array to iterate over.

Return:

@return (int | null) Returns the maximum value.

Example:

maxBy

This method is like max except that it accepts iteratee which is invoked for each element in array to generate the criterion by which the value is ranked. The iteratee is invoked with one argument: (value).

Arguments:

@param array $array The array to iterate over.

@param (callable | string) $iteratee The iteratee invoked per element.

Return:

@return mixed Returns the maximum value.

Example:

Number

clamp

Clamps number within the inclusive lower and upper bounds.

Arguments:

@param int $number The number to clamp.

@param int $lower The lower bound.

@param int $upper The upper bound.

Return:

@return int Returns the clamped number.

Example:

inRange

Checks if number is between start and up to, but not including, end. If end is not specified, it's set to start with start then set to 0. If start is greater than end the params are swapped to support negative ranges.

Arguments:

@param float $number The number to check.

@param float $start The start of the range.

@param float $end The end of the range.

Return:

@return boolean Returns true if number is in the range, else false.

Example:

random

Produces a random number between the inclusive lower and upper bounds. If only one argument is provided a number between 0 and the given number is returned. If floating is true, or either lower or upper are floats, a floating-point number is returned instead of an integer.

Arguments:

@param (int | float | bool) $lower The lower bound.

@param (int | float | bool) $upper The upper bound.

@param (bool | null) $floating Specify returning a floating-point number.

Return:

@return (int | float) Returns the random number.

Example:

Object

get

Gets the value at path of object. If the resolved value is null the defaultValue is returned in its place.

Arguments:

@param mixed $object The associative array or object to fetch value from

@param (array | string) $path Dot separated or array of string

@param mixed $defaultValue (optional)The value returned for unresolved or null values.

Return:

@return mixed Returns the resolved value.

Example:

pick

Creates an object composed of the picked object properties.

Arguments:

@param object $object The source object.

@param (string | string[]) $paths The property paths to pick.

Return:

@return \stdClass Returns the new object.

Example:

pickBy

Creates an object composed of the object properties predicate returns truthy for. The predicate is invoked with two arguments: (value, key).

Arguments:

@param (object | null) $object The source object.

@param callable $predicate The function invoked per property.

Return:

@return \stdClass Returns the new object.

Example:

Seq

chain

Creates a lodash wrapper instance that wraps value with explicit method chain sequences enabled. The result of such sequences must be unwrapped with ->value().

Arguments:

@param mixed $value The value to wrap.

Return:

@return _ Returns the new lodash wrapper instance.

Example:

String

camelCase

Converts string to camel case.

Arguments:

@param string $string The string to convert.

Return:

@return string Returns the camel cased string.

Example:

capitalize

Converts the first character of string to upper case and the remaining to lower case.

Arguments:

@param string $string The string to capitalize.

Return:

@return string Returns the capitalized string.

Example:

deburr

Deburrs string by converting [Latin-1 Supplement](https =>//en.wikipedia.org/wiki/Latin-1Supplement(Unicode_block)#Character_table) and [Latin Extended-A](https =>//en.wikipedia.org/wiki/Latin_Extended-A) letters to basic Latin letters and removing [combining diacritical marks](https =>//en.wikipedia.org/wiki/Combining_Diacritical_Marks).

Arguments:

@param string $string The string to deburr.

Return:

@return string Returns the deburred string.

Example:

endsWith

Checks if string ends with the given target string.

Arguments:

@param string $string The string to inspect.

@param string $target The string to search for.

@param int $position The position to search up to.

Return:

@return boolean Returns true if string ends with target, else false.

Example:

escape

Converts the characters "&", "<", ">", '"', and "'" in string to their corresponding HTML entities.

Though the ">" character is escaped for symmetry, characters like ">" and "/" don't need escaping in HTML and have no special meaning unless they're part of a tag or unquoted attribute value. See Mathias Bynens's article (under "semi-related fun fact") for more details.

When working with HTML you should always quote attribute values to reduce XSS vectors.

Arguments:

@param string $string The string to escape.

Return:

@return string Returns the escaped string.

Example:

escapeRegExp

Escapes the RegExp special characters "^", "$", "\", ".", "*", "+", "?", "(", ")", "[", "]", "{", "}", and "|" in string.

Arguments:

@param string $string The string to escape.

Return:

@return string Returns the escaped string.

Example:

kebabCase

Converts string to kebab case.

Arguments:

@param string $string The string to convert.

Return:

@return string Returns the kebab cased string.

Example:

lowerCase

Converts string, as space separated words, to lower case.

Arguments:

@param string $string The string to convert.

Return:

@return string Returns the lower cased string.

Example:

lowerFirst

Converts the first character of string to lower case.

Arguments:

@param string $string The string to convert.

Return:

@return string Returns the converted string.

Example:

pad

Pads string on the left and right sides if it's shorter than length. Padding characters are truncated if they can't be evenly divided by length.

Arguments:

@param string $string The string to pad.

@param int $length The padding length.

@param string $chars The string used as padding.

Return:

@return string Returns the padded string.

Example:

padEnd

Pads string on the right side if it's shorter than length. Padding characters are truncated if they exceed length.

Arguments:

@param string $string The string to pad.

@param int $length The padding length.

@param string $chars The string used as padding.

Return:

@return string Returns the padded string.

Example:

padStart

Pads string on the left side if it's shorter than length. Padding characters are truncated if they exceed length.

s Arguments:

@param string $string ='' The string to pad.

@param int $length The padding length.

@param string $chars The string used as padding.

Return:

@return string Returns the padded string.

Example:

parseInt

Converts string to an integer of the specified radix. If radix is undefined or 0, a radix of 10 is used unless string is a hexadecimal, in which case a radix of 16 is used.

Note: This method uses PHP's built-in integer casting, which does not necessarily align with the ES5 implementation of parseInt.

Arguments:

@param (int | float | string) $string The string to convert.

@param int $radix The radix to interpret string by.

Return:

@return int Returns the converted integer.

Example:

repeat

Repeats the given string n times.

Arguments:

@param string $string The string to repeat.

@param int $n The number of times to repeat the string.

Return:

@return string Returns the repeated string.

Example:

replace

Replaces matches for pattern in string with replacement.

Note: This method is based on String#replace.

Arguments:

@param string $string The string to modify.

@param string $pattern The pattern to replace.

@param (callable | string) $replacement The match replacement.

Return:

@return string Returns the modified string.

Example:

snakeCase

Converts string to snake case.

Arguments:

@param string $string The string to convert.

Return:

@return string Returns the snake cased string.

Example:

split

Splits string by separator.

Note: This method is based on String#split.

Arguments:

@param string $string The string to split.

@param string $separator The separator pattern to split by.

@param int $limit The length to truncate results to.

Return:

@return array Returns the string segments.

Example:

startCase

Converts string to start case.

Arguments:

@param string $string The string to convert.

Return:

@return string Returns the start cased string.

Example:

startsWith

Checks if string starts with the given target string.

Arguments:

@param string $string The string to inspect.

@param string $target The string to search for.

@param int $position The position to search from.

Return:

@return boolean Returns true if string starts with target, else false.

Example:

template

Creates a compiled template function that can interpolate data properties in "interpolate" delimiters, HTML-escape interpolated data properties in "escape" delimiters, and execute PHP in "evaluate" delimiters. Data properties may be accessed as free variables in the template. If a setting object is given, it takes precedence over $templateSettings values.

RegExp $options['escape'] = ::$templateSettings['escape'] The HTML "escape" delimiter. RegExp $options['evaluate'] = ::$templateSettings['evaluate'] The "evaluate" delimiter. array $options['imports'] = ::$templateSettings['imports'] An object to import into the template as free variables. RegExp $options['interpolate'] = ::$templateSettings['interpolate'] The "interpolate" delimiter.

Arguments:

@param string $string The template string.

@param array $options The options array.

Return:

@return callable Returns the compiled template function.

Example:

toLower

Converts string, as a whole, to lower case

Arguments:

@param string $string The string to convert.

Return:

@return string Returns the lower cased string.

Example:

toUpper

Converts string, as a whole, to upper case

Arguments:

@param string $string The string to convert.

Return:

@return string Returns the upper cased string.

Example:

trim

Removes leading and trailing whitespace or specified characters from string.

Arguments:

@param string $string The string to trim.

@param string $chars The characters to trim.

Return:

@return string Returns the trimmed string.

Example:

trimEnd

Removes trailing whitespace or specified characters from string.

Arguments:

@param string $string The string to trim.

@param string $chars The characters to trim.

Return:

@return string Returns the trimmed string.

Example:

trimStart

Removes leading whitespace or specified characters from string.

Arguments:

@param string $string The string to trim.

@param string $chars The characters to trim.

Return:

@return string Returns the trimmed string.

Example:

truncate

Truncates string if it's longer than the given maximum string length. The last characters of the truncated string are replaced with the omission string which defaults to "...".

length = 30 The maximum string length. omission = '...' The string to indicate text is omitted. separator The separator pattern to truncate to.

Arguments:

@param string $string The string to truncate.

@param array $options The options object.

Return:

@return string Returns the truncated string.

Example:

unescape

The inverse of escapethis method converts the HTML entities &amp;, &lt;, &gt;, &quot; and &#39; in string to their corresponding characters.

Arguments:

@param string $string The string to unescape.

Return:

@return string Returns the unescaped string.

Example:

upperCase

Converts string, as space separated words, to upper case.

Arguments:

@param string $string The string to convert.

Return:

@return string Returns the upper cased string.s

Example:

upperFirst

Converts the first character of string to upper case.

Arguments:

@param string $string The string to convert.

Return:

@return string Returns the converted string.

Example:

words

Splits string into an array of its words.

Arguments:

@param string $string The string to inspect.

@param string $pattern The pattern to match words.

Return:

@return array Returns the words of string.

Example:

Util

attempt

Attempts to invoke func, returning either the result or the caught error object. Any additional arguments are provided to func when it's invoked.

s Arguments:

@param callable $func The function to attempt.

@param array<int, mixed> $args The arguments to invoke func with.

Return:

@return (mixed | \Throwable) Returns the func result or error object.

Example:

defaultTo

Checks value to determine whether a default value should be returned in its place. The defaultValue is returned if value is NaN or null.

Arguments:

@param mixed $value Any value.

@param mixed $defaultValue Value to return when $value is null or NAN

Return:

@return mixed Returns value.

Example:

identity

This method returns the first argument it receives.

Arguments:

@param mixed $value Any value.

Return:

@return mixed Returns value.

Example:

property

Creates a function that returns the value at path of a given object.

Arguments:

@param (array | string) $path The path of the property to get.

Return:

@return callable Returns the new accessor function.

Example:


All versions of lodash-php with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
sebastian/comparator Version ^1.2 | ^2.0 | ^2.1 | ^3.0 | ^4.0 | ^5.0 | ^6.0
symfony/property-access Version ^2.7 | ^3.0 | ^4.0 | ^5.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package northwestern-sysdev/lodash-php contains the following files

Loading the files please wait ....