Download the PHP package overthink/array-item without Composer

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

Array Item

Latest Version on Packagist GitHub Tests Action Status GitHub Code Style Action Status Total Downloads

A fluent, typed accessor for reading and manipulating array data in Laravel apps. Wrap any array (API response, JSON column, config, ...) in an ArrayItem to get dot-notation access, typed getters (string, float, date, number, collection, JSON), and a small set of array manipulation helpers, without giving up ArrayAccess.

Requirements

Need Laravel 10 / PHP 8.2? Use ^1.0 instead — it won't get new features, but it's still there.

Installation

You can install the package via composer:

You can publish the config file with:

Usage

Available methods

Method Description
make(array\|ArrayItem $attributes = []) Create a new instance (static).
default(array $attributes): array Overridable hook to seed default attributes on construction.
get(string\|callable $key, mixed $default = null) Dot-notation get, or resolve a callable against the item.
getOr(string\|callable $key, mixed $default = null) Like get(), but falls back to $default when the value is empty().
has(string $key): bool Dot-notation existence check.
set(string\|callable $key, mixed $value = null, bool $merge = false) Dot-notation set; a callable replaces (or merges into) all attributes.
merge(string\|callable $key, mixed $value = null) Shorthand for set(..., merge: true).
only(string\|array\|Collection $keys) Keep only the given keys (supports ['from' => 'to'] remapping).
remove(string\|array\|Collection $keys) Remove the given keys.
string(string\|callable $key, string $default = '') Get the value as an Illuminate\Support\Stringable.
float(string\|callable $key, ?string $default = null): float Parse the value as a float, handling "1.234,56"-style European numbers.
number(string\|callable $key, ?string $default = null): Number Get the value wrapped in a Number helper (see below).
numberFormat(string\|callable $key, ?int $decimals, ?string $decimalSeparator, ?string $thousandsSeparator, ?string $default): string number_format() over float(), using the static defaults below when omitted.
collect(string\|callable $key, mixed $default = []): Collection Get the value as a Collection.
json(string\|callable $key, mixed $default = null): mixed json_decode() the value.
jsonItem(string\|callable $key, mixed $default = null): ArrayItem Decode the value and wrap it in a new ArrayItem.
date(string\|callable $key, ?string $default = null): ?Carbon Parse the value as a Carbon date.
dateFrom(string\|callable $key, string $from, ?string $default = null): ?Carbon Parse the value with an explicit input format.
dateFormat(string\|callable $key, ?string $format = null, ?string $default = null): ?string Format a date value, defaulting to static::$dateFormat.
timestamp(string\|callable $key, ?string $default = null): ?Carbon Parse the value as a unix timestamp.
timestampFormat(string\|callable $key, ?string $format = null, ?string $default = null): ?string Format a timestamp value, defaulting to static::$dateFormat.
convert(string\|callable $key, Convertable $converter, mixed $default = null) Pass the value through a custom Convertable implementation.
getAttributes(): array / toArray(): array Get the raw underlying array.
toCollection(): Collection Get the underlying array as a Collection.
toJson($options = 0): string / __toString() JSON-encode the item.

ArrayItem also implements ArrayAccess ($item['key']), Illuminate\Contracts\Support\Arrayable, Jsonable, JsonSerializable, and uses Laravel's Conditionable (when()/unless()) and Macroable traits.

Conditionable

Conditionally apply logic while staying in the fluent chain:

Macroable

Register your own methods on ArrayItem at boot time:

Static configuration, shared across all instances:

Number

ArrayItem::number() returns an Overthink\ArrayItem\Number instance, a thin wrapper around Illuminate\Support\Number:

convert() and Convertable

Custom conversion logic can be plugged in via the Convertable interface:

Testing

Changelog

Please see CHANGELOG for more information on what has changed recently.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

License

The MIT License (MIT). Please see License File for more information.


All versions of array-item with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
spatie/laravel-package-tools Version ^1.14.0
illuminate/contracts Version ^10.48
illuminate/support Version ^10.48
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 overthink/array-item contains the following files

Loading the files please wait ...