Download the PHP package babenkoivan/fluent-array without Composer

On this page you can find all versions of the php package babenkoivan/fluent-array. 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 fluent-array

FluentArray

Packagist Packagist Build Status license Donate

Introduction

The fluent array library provides you with a convenient chainable interface. If you like object-oriented syntax or you just want to have more readable array declaration, the fluent array is at your service.

Basic usage

If we convert the fluent array to an associative array, by calling $order->toArray(), we will get the following output:

Storage array

Every time you call get, or any other method, that modifies or retrieves the state, you update the internal storage of fluent array.

Installation

Use composer to install the library:

Configuration

The configuration allows you to change a fluent array new functionality.

Local scope

To configure a specific fluent array instance use local scope.

Global scope

To configure all fluent arrays use global scope.

Macros

You can use macros to extend a fluent array functionality. It can be done via configuration in local scope.

Naming strategies

Naming strategies describe key transformation in dynamic methods.

For example, we want all our keys to be underscored in the storage array.

Now we want them to be camel-cased.

The supported naming strategies are:

Strategy Example
CamelCaseStrategy MyValue
NullStrategy myValue
UnderscoreStrategy my_value

The default naming strategy is UnderscoreStrategy.

Fixed methods

all

The all method returns the storage array.

clean

The clean method removes all keys and values from the storage array.

config

The config method allows you to set or retrieve local configuration.

count

The count method returns the amount of values in the storage array.

each

The each method iterates over the values in the storage array.

To stop the iteration return false from the callback.

filter

The filter method filters the storage array using the given callback. Return false from the callback to remove a value.

If callback is not specified, all values, that can be converted to false will be removed.

first

The first method retrieves the first value from the storage array.

fromArray

The fromArray method converts an array to a fluent array.

fromJson

The fromJson method converts JSON to a fluent array.

get

The get method retrieves the value from the storage array, that corresponds the given key.

globalConfig

The globalConfig method allows you to set or retrieve global configuration.

has

The has method checks if the given key exists in the storage array.

keys

The keys method retrieves all the keys from the storage array.

krsort

The krsort method sorts the storage array by keys in descending order. You can specify sort flags as a first argument.

ksort

The ksort method sorts the storage array by keys in ascending order. You can specify sort flags as a first parameter.

last

The last method retrieves the last value from the storage array.

map

The map method applies the given callback to all values in the storage array and returns a new fluent array.

pluck

The pluck method extracts values with the given key, from child fluent arrays to a new fluent array.

push

The push method appends the given value to the storage array.

Another way of using the push method:

pushWhen

The pushWhen method appends the given value to the storage array, if the first argument is equivalent to true.

Another way of using the pushWhen method:

rsort

The rsort method sorts the storage array in descending order. You can specify sort flags as a first parameter.

set

The set method sets the given key and value in the storage array.

setWhen

The setWhen method sets the given key and value in the storage array, if the first argument is equivalent to true.

sort

The sort method sorts the storage array in ascending order. You can specify sort flags as a first parameter.

toArray

The toArray method converts a fluent array to an array.

toJson

The toJson method converts a fluent array to JSON.

unset

The unset method removes the storage array value by the given key.

usort

The usort method sorts the storage array using the given comparison function.

values

The values method retrieves all the values from the storage array.

when

The when method executes the given callback, if the first argument is equivalent to true.

You can specify a default callback, that will be executed, if the first argument is equivalent to false.

Dynamic methods

Dynamic setter

You can also set a key-value pair in the storage array using a dynamic setter.

If you want to set the key, that is reserved for a method name, you can escape it.

Add When to set the given value if the first argument is equivalent to true.

You can also chain creation of child fluent arrays.

Dynamic getter

To retrieve a value from the storage array you can use a dynamic getter.

Dynamic has

To check if a key exists in the storage array you can use a dynamic has method.

Dynamic pluck

To extract values from child fluent arrays you can use a dynamic pluck method.

Dynamic unset

To remove a value from the storage array you can use a dynamic unset method.

Implemented interfaces

Countable

The Countable interface provides the count method support. See more here.

Serializable

The Serializable interface provides serialization support. See more here.

ArrayAccess

The ArrayAccess interface provides array access. See more here.

IteratorAggregate

The IteratorAggregate interface enables iteration over the storage array. See more here.

Code formatting

If you use PhpStorm and code auto formatting, you will likely face the issue, that the following code:

Will be transformed by PhpStorm to:

Now the code is less readable, but luckily we can configure PhpStorm to disable auto formatting the specified peace of code. To do so, open PhpStorm preferences, go to the Editor > Code Style section and select option Enable formatter markers in comments.

Now you can turn the formatter off for the specific part of your code:


All versions of fluent-array with dependencies

PHP Build Version
Package Version
Requires php Version ^7.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 babenkoivan/fluent-array contains the following files

Loading the files please wait ....