Download the PHP package hansel23/generic-lists without Composer

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

Build Status Coverage Status Latest Stable Version Latest Unstable Version Total Downloads License

GenericList

Generic list with interface. It's based on the list type of some other famous languages, like java or c#

My Motivation

I like strong typing. I think it makes the code more stable and easier to understand.

I want to be sure to have certain objects in the list and not only trust to have the right object in the array.

I like the methods of the list types of other languages like java or c#. They are often usefull.

Usage

You can build an instance of the GenericList on the fly: new GenericList( YourOwnType::class )

Recommended usage:

  1. create a new type, e.g. YourOwnTypeList
  2. extend this type from GenericList
  3. override the constructor: public function __construct() { parent::__construct( YourOwnType::class ) }

Now you can use typehints for this list.

You can iterate over the list like you do it with a normal array.

Also there are many useful methods:

All exceptions are extended from the ListException.

List Sorters

To sort a list, you have to create a sorter, that implements the SortsLists interface.

The implementation of the method compare( $object1, $object2 ) must return an integer less than, equal to, or greater than zero if the first argument is considered to be respectively less than, equal to, or greater than the second.

Pass an instance of your sorter implementation to the method sortBy of the list.

List Filters

To filter a list, you have to create a filter, that implements the FindsItems interface with the isValid( $object ) method. This method must return a boolean value to indicate whether the object matches to the filter and should be returned or not.

Pass an instance of your filter implementation to the method find, findLast or findAll of the list. Find and findLast will return one object (first or last) that matches your filter method and findAll will return a new list of the same type that contains all objects filtered by your filter.

Example

using list type directly

creating the list type

creating a sorter

using typehint for the list and sort with the created sorter

creating a filter

using the filter


All versions of generic-lists with dependencies

PHP Build Version
Package Version
Requires php Version >=5.5
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 hansel23/generic-lists contains the following files

Loading the files please wait ....