Collections Abstraction library for PHP

Overview

Collections

Build Status Scrutinizer Code Quality Code Coverage Latest Stable Version Downloads

Collections Abstraction library for PHP

The Collection library is one of the most useful things that many modern languages has, but for some reason PHP doesn't has a built in collection layer.

For that reason we created Collections, an incredible library that gathers the best of .NET's and Java's collections patterns and unify it with PHP array power.

Take a look and see what we're talking about!!

Install

composer require easyframework/collections

Usage

The Collection Class

The Collection represents the List in .NET language or simply non-associative arrays in php:

  $person1 = new \stdClass();
  $person1->name = 'John';
  $person1->age = 25;
  
  $person2 = new \stdClass();
  $person2->name = 'Maria';
  $person2->age = 30;
  
  $person3 = new \stdClass();
  $person3->name = 'Anderson';
  $person3->age = 15;
     
  $collection = new Collections\Vector();
  $collection->add($person1);
  $collection->add($person2);
  $collection->add($person3);
  
  $collection->filter(function($person){
        return $person->age > 18;
  })->each(function($item){
        echo $item->name; //John and Maria
  });

Contributing

Please see CONTRIBUTING for details.

License

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

Documentation

More information can be found in the online documentation at https://italolelis.gitbooks.io/collections.

Comments
  • PHP 7.1 production support

    PHP 7.1 production support

    Hello @italolelis @kieranajp !

    Thanks for your work on this lib, I saw you added php 7.1 support last month.

    Is it possible to add to tag to use it in production ?

    TY

    opened by Th3Mouk 1
  • Completing comparer tests

    Completing comparer tests

    This PR just adds two tests to finish out the coverage on the NumericKeyComparer Class.

    A couple screenshots to demonstrate the small change in coverage.

    Before: 2016-08-20_2237 2016-08-20_22371

    After: 2016-08-20_2240 2016-08-20_2238

    opened by jhoughtelin 1
  • Set should only have unique values

    Set should only have unique values

    The Set-class should only allow unique values, as this is the most used behavior for a Set.

    Hack, Java, TypeScript all only allow unique values in a Set.

    opened by fMads 1
  • toValuesArray without keys

    toValuesArray without keys

    If let's say we have Dictionary with one element: key -> 111:11:11 and value -> object and when we need to do toValuesArray i expect to get only values in that array but not key values array it might be another one for that purpose like toKeyValuesArray (toArray does this) to keep keys from Dictionary

    opened by robertke 1
  • Create Set class

    Create Set class

    Create Set data structure, something like hack Set:

    http://docs.hhvm.com/hack/reference/class/Set/

    The interfaces are already created, so we just need to implement them.

    Easy Pick Feature 
    opened by italolelis 1
  • Feature improve code quality

    Feature improve code quality

    This feature is all about code quality, let's get back to top score on scrutinizer! A lot of issues were fixed, but there is still some work to do.

    Except of recommended changes I also added a lot of codeblocks add did some variable renaming with more meaningful and consistent names.

    Feel free to ask me to correct something.

    opened by vladimino 0
  • Scrutinizer Auto-Fixes

    Scrutinizer Auto-Fixes

    @italolelis requested this pull request.

    This patch was automatically generated as part of the following inspection: https://scrutinizer-ci.com/g/LellysInformatica/collections/inspections/aad921df-a5f4-4f7a-9003-3e43125b4f96

    Enabled analysis tools:

    • PHP Analyzer
    • PHP Mess Detector
    • PHP Code Sniffer
    • Security Advisory Checker
    • PHP Copy/Paste Detector
    • PHP Lines Of Code
    • PHP PDepend
    opened by scrutinizer-auto-fixer 0
  • Improve documentation

    Improve documentation

    The library's documentation is generated using read the docs service.

    I really would appreciate some help to improve the documentation of the library, once I have a little time to contribute with this.

    Thank you very much for this.

    Help Needed 
    opened by italolelis 0
Releases(v7.0.0)
Owner
Ítalo Vietro
I'm a Software Engineer that loves Go, Kubernetes and anything Open Source!
Ítalo Vietro
PHP Integrated Query, a real LINQ library for PHP

PHP Integrated Query - Official site What is PINQ? Based off the .NET's LINQ (Language integrated query), PINQ unifies querying across arrays/iterator

Elliot Levin 465 Dec 30, 2022
🗃 Array manipulation library for PHP, called Arrayy!

?? Arrayy A PHP array manipulation library. Compatible with PHP 7+ & PHP 8+ \Arrayy\Type\StringCollection::create(['Array', 'Array'])->unique()->appen

Lars Moelleken 430 Jan 5, 2023
Library for (de-)serializing data of any complexity (supports JSON, and XML)

jms/serializer Introduction This library allows you to (de-)serialize data of any complexity. Currently, it supports XML and JSON. It also provides yo

Johannes 2.2k Jan 1, 2023
:lipstick: Scalable and durable all-purpose data import library for publishing APIs and SDKs.

Porter Scalable and durable data imports for publishing and consuming APIs Porter is the all-purpose PHP data importer. She fetches data from anywhere

null 594 Jan 1, 2023
[READ-ONLY] Collection library in CakePHP. This repo is a split of the main code that can be found in https://github.com/cakephp/cakephp

CakePHP Collection Library The collection classes provide a set of tools to manipulate arrays or Traversable objects. If you have ever used underscore

CakePHP 85 Nov 28, 2022
True asynchronous PHP I/O and HTTP without frameworks, extensions, or annoying code. Uses the accepted Fibers RFC to be implemented into PHP 8.1

PHP Fibers - Async Examples Without External Dependencies True asynchronous PHP I/O and HTTP without frameworks, extensions, or annoying code behemoth

Cole Green 121 Jan 6, 2023
Map nested JSON structures onto PHP classes

JsonMapper - map nested JSON structures onto PHP classes Takes data retrieved from a JSON web service and converts them into nested object and arrays

Christian Weiske 1.4k Dec 30, 2022
Yet Another LINQ to Objects for PHP [Simplified BSD]

YaLinqo: Yet Another LINQ to Objects for PHP Online documentation GitHub repository Features The most complete port of .NET LINQ to PHP, with many add

Alexander Prokhorov 436 Jan 3, 2023
`LINQ to Object` inspired DSL for PHP

Ginq Array handling in PHP? Be happy with Ginq! Ginq is a DSL that can handle arrays and iterators of PHP unified. Ginq is inspired by Linq to Object,

Atsushi Kanehara 191 Dec 19, 2022
A repository with implementations of different data structures and algorithms using PHP

PHP Data Structures and Algorithms Data structure and Algorithm is always important for any programming language. PHP, being one of the most popular l

Mizanur Rahman 610 Jan 2, 2023
Leetcode for PHP, five questions a week and weekends are updated irregularly

✏️ Leetcode for PHP why do you have to sleep for a long time ,and naturally sleep after death 联系 说明 由于目前工作主要是 golang,我又新起了一个LeetCode-Go-Week项目,- Leetc

吴亲库里 370 Dec 29, 2022
Missing data types for PHP. Highly extendable.

Neverending data validation can be exhausting. Either you have to validate your data over and over again in every function you use it, or you have to rely it has already been validated somewhere else and risk potential problems.

SmartEmailing 82 Nov 11, 2022
JsonMapper - map nested JSON structures onto PHP classes

Takes data retrieved from a JSON web service and converts them into nested object and arrays - using your own model classes.

Netresearch 9 Aug 21, 2022
All Algorithms implemented in Php

The Algorithms - PHP All algorithms implemented in Php (for education) These implementations are for learning purposes. They may be less efficient tha

The Algorithms 1k Dec 27, 2022
A community driven collection of sorting algorithms in PHP

algorithms A community driven collection of sorting algorithms This repository includes a comma separated file that includes 10k numbers between 1 and

Andrew S Erwin 0 May 16, 2022
Iterators - The missing PHP iterators.

PHP Iterators Description The missing PHP iterators. Features CachingIteratorAggregate ClosureIterator: ClosureIterator(callable $callable, array $arg

(infinite) loophp 24 Dec 21, 2022
A Collections library for PHP.

A Library of Collections for OO Programming While developing and helping others develop PHP applications I noticed the trend to use PHP's arrays in ne

Levi Morrison 629 Nov 20, 2022
QuidPHP/Main is a PHP library that provides a set of base objects and collections that can be extended to build something more specific.

QuidPHP/Main is a PHP library that provides a set of base objects and collections that can be extended to build something more specific. It is part of the QuidPHP package and can also be used standalone.

QuidPHP 4 Jul 2, 2022
PHP library that provides a filesystem abstraction layer − will be a feast for your files!

Gaufrette Gaufrette provides a filesystem abstraction layer. Why use Gaufrette? Imagine you have to manage a lot of medias in a PHP project. Lets see

KNP Labs 2.4k Jan 7, 2023
🐼 Framework agnostic package using asynchronous HTTP requests and PHP generators to load paginated items of JSON APIs into Laravel lazy collections.

Framework agnostic package using asynchronous HTTP requests and generators to load paginated items of JSON APIs into Laravel lazy collections.

Andrea Marco Sartori 61 Dec 3, 2022