2017 © Pedro PelĂĄez
 

library objectcollection

A very simple library to handle object lists on php

image

mittax/objectcollection

A very simple library to handle object lists on php

  • Friday, December 23, 2016
  • by mittax
  • Repository
  • 1 Watchers
  • 0 Stars
  • 9 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 11 Versions
  • 0 % Grown

The README.md

Simple ObjectCollection library

Helps you build typed lists with php >=7.0

Install

composer require mittax/objectcollection

Usage

Create a subclass of objectCollectionAbstract which adds a list of objects to the collection by the constructor, (*1)

Here is a sample abstraction. Further have a look in Tests. There are some basic usages documented, (*2)

<?php
/**
 * Created by PhpStorm.
 * User: pboethig
 * Date: 14.12.16
 * Time: 20:10
 */

namespace Mittax\MediaConverterBundle\Collection;
use Mittax\ObjectCollection\CollectionAbstract;

/**
 * Class StorageItem
 * @package Mittax\MediaConverterBundle\Collection
 */
class StorageItem extends CollectionAbstract
{

    /**
     * StorageItem constructor.
     * @param \Mittax\MediaConverterBundle\Entity\Storage\StorageItem[] $items
     */
    public function __construct(Array $items)
    {
        parent::__construct();

        foreach ($items as $item)
        {
            $this->add($item);
        }
    }

    /**
     * @param $filename
     * @return \Mittax\MediaConverterBundle\Entity\Storage\StorageItem[]
     */
    public function filterByFilename( string $filename) : Array
    {
        return $this->filterByPropertyNameAndValue('filename', $filename);
    }

    /**
     * @return \Mittax\MediaConverterBundle\Entity\Storage\StorageItem
     */
    public function getFirstItem() : \Mittax\MediaConverterBundle\Entity\Storage\StorageItem
    {
        return parent::getFirstItem();
    }

    /**
     * @return \Mittax\MediaConverterBundle\Entity\Storage\StorageItem[]
     */
    public function getAllItems() : Array
    {
        return parent::getAllItems();
    }
}

Use the abstraction

Just instanciate your abstraction subclass and pass an array with your object to the constructor. The resulting collection is typed of your context, (*3)

        $items = [$fileStorageItem, $fileStorageItem1, $fileStorageItem1];

        $collection = new Collection\StorageItem($items);

        $collection->filter($fileStorageItem->getFilename());

The result is a typed list from type StorageItem, (*4)

Run tests

phpunit

The Versions

23/12 2016

dev-master

9999999-dev

A very simple library to handle object lists on php

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

20/12 2016

0.1.0

0.1.0.0

A very simple library to handle object lists on php

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

17/12 2016

0.0.9

0.0.9.0

A very simple library to handle object lists on php

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

17/12 2016

0.0.8

0.0.8.0

A very simple library to handle object lists on php

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

17/12 2016

0.0.7

0.0.7.0

A very simple library to handle object lists on php

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

16/12 2016

0.0.6

0.0.6.0

A very simple library to handle object lists on php

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

15/12 2016

0.0.5

0.0.5.0

A very simple library to handle object lists on php

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

15/12 2016

0.0.4

0.0.4.0

A very simple library to handle object lists on php

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

15/12 2016

0.0.3

0.0.3.0

A very simple library to handle object lists on php

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

15/12 2016

0.0.2

0.0.2.0

A very simple library to handle object lists on php

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires

15/12 2016

0.0.1

0.0.1.0

A very simple library to handle object lists on php

  Sources   Download

MIT

The Requires

  • php >=7.0

 

The Development Requires