Download the PHP package cocur/collection without Composer

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

Cocur\Collection

Arrays are great, but sometimes the items need to know the thing they are a part of. Then you need a Collection.

Build Status Windows Build status Scrutinizer Code Quality Code Coverage StyleCI

Developed by Florian Eckerstorfer (Twitter) in Vienna, Europe.

Installation

Usage

The most important part of Collection are it's interfaces. They make your collection interoperable with other libraries. However, this library also contains implementations that are ready to use.

Interfaces

Implementations

CollectionInterface

Cocur\Collection\CollectionInterface defines the basic methods of a collection and extends IteratorAggregate and Countable.

When calling add() the collection should call the setCollection() method of the item and set itself as its collection.

Should return an iterator to iterate through the items of the collection.

Should return the number of items in the collection.

ItemInterface

Cocur\Collection\ItemInterface defines two methods: setCollection() and getCollection().

Should store a reference to the collection in the item.

Should return a reference to the collection or null if the item does not have a collection.

Collection

Cocur\Collection\Collection implements Cocur\Collection\CollectionInterface and uses a simple array to keep track of its items.

AbstractItem

Cocur\Collection\AbstractItem implements the methods from Cocur\Collection\ItemInterface. It simply sets and gets the collection and is great if you don't need a specific logic on how to set and get the collection on an item.

AbstractItem is, as its name suggests, an abstract class and you need to extend it.

Item

Cocur\Collection\Item extends Cocur\Collection\AbstractItem and in addition to the setCollection() and getCollection() methods also implements setValue() and getValue() to set and get an arbitrary value. You can wrap Item around a scalar value or around an object that is out of your control and does not implement ItemInterface.

In addition Cocur\Collection\Item has a factory method called ::create():

ArrayItem

While Item stores a single value, Cocur\Collection\ArrayItem is meant to hold an array. It implements methods to set, get and remove elements from the item as well as to check for their existence. In addition the toArray() method returns the underlying array.

The get() and remove() methods throw an OutOfBoundsException if the element with the given key does not exist. However, instead of throwing an exception get() can also return a default value if one is provided as second argument.

You can create new instances using the static ::createFromArray() method:

Because ArrayItem implements ArrayAccess, IteratorAggregate and Countable you can use it in most cases just like you would use an array.

Change Log

Version 0.1.1 (18 May 2015)

Version 0.1 (28 April 2015)

License

The MIT license applies to cocur/collection. For the full copyright and license information, please view the LICENSE file distributed with this source code.


All versions of collection with dependencies

PHP Build Version
Package Version
No informations.
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 cocur/collection contains the following files

Loading the files please wait ....