Download the PHP package talesoft/tale-iterator without Composer

On this page you can find all versions of the php package talesoft/tale-iterator. 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 tale-iterator

Packagist License CI Coverage

Tale Iterator

What is Tale Iterator?

Tale Iterator extends the SPL iterators by some more, useful iterators for common use-cases.

Installation

Usage

MapIterator

Maps values by a map()-method. You mostly want to extend it and override the map()-method.

Stack with FlipIterator to map keys (see "How do I XYZ" at the bottom of this README)

CallbackMapIterator

Maps values by specifying a simple callback.

Stack with FlipIterator to map keys (see "How do I XYZ" at the bottom of this README)

FilterIterator

Filters values by an accept()-method. You mostly want to extend it and override the accept()-method. It will preserve keys!. If you want to reset the keys, chain a ValueIterator as shown below.

Stack with FlipIterator to filter keys (see "How do I XYZ" at the bottom of this README)

CallbackFilterIterator

Filters values by specifying a simple callback.

Stack with FlipIterator to filter keys (see "How do I XYZ" at the bottom of this README)

Note:

PHP already has a FilterIterator and a CallbackFilterIterator, but it only accepts instances of \Iterator, which doesn't include \IteratorAggregate instances. This one accepts instances of \Traversable, which includes all iterables except for objects and native arrays (which are covered, too, keep reading). It uses the same API as the PHP implementation, though!

IterableIterator

This is a small utility iterator that turns any iterable into a valid iterator. It's equivalent to an \IteratorIterator, that normalizes the passed iterable to

$iterable instanceof \Traversable ? $iterable : new \ArrayIterator($iterable).

With this iterator, you can pass any kind of iterable, arrays, objects, generators etc. to an iterator that only accepts \Iterator instances easily.

This is useful for PHPs SPL iterators or other iterator implementations that don't leverage iterable or \Traversable and rely on \Iterator only and/or do this for a very good reason

ValueIterator

This is basically array_values() for iterators. This is useful to e.g. reset the keys for FilterIterator outputs.

KeyIterator

This is basically array_keys() for iterators. This is useful if you want to get a clean list of the inner iterators keys.

FlipIterator

This iterator will flip keys and values. This is often useful if you want outer iterators act on keys rather than on values.

Through the way iterators work, as long as you don't flatten the iterator to an array, duplicate values won't result on dropped keys! Notice the second example to understand what I mean.

With array_flip, duplicate values will lead to dropped keys, as array keys have to be unique. With iterators, this isn't the case as long as you don't actually flatten it!

FormatIterator

This is basically sprintf($format, $current) on each value in the iterator.

Stack with FlipIterator to format keys (see "How do I XYZ" at the bottom of this README)

PrefixIterator

This is $prefix.$current for each value in the iterator.

Stack with FlipIterator to prefix keys (see "How do I XYZ" at the bottom of this README)

SuffixIterator

This is $current.$suffix for each value in the iterator.

Stack with FlipIterator to suffix keys (see "How do I XYZ" at the bottom of this README)

IndexIterator

This iterator counts an independent index during iteration and makes it available. This is useful to count the amount of iterations, mostly. ValueIterator and KeyIterator use this to reset the keys.

How to do XYZ?

How to map keys instead of values?

Easy, through chaining a MapIterator and FlipIterators! Notice this doesn't create any additional overhead except for function calls. The internal array is as no point copied or even modified.

How to filter keys instead of values?

Here, again, the FlipIterator does everything you need!


All versions of tale-iterator with dependencies

PHP Build Version
Package Version
Requires php Version >=7.1.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 talesoft/tale-iterator contains the following files

Loading the files please wait ....