2017 © Pedro Peláez
 

library collectors

image

arrilot/collectors

  • Thursday, December 7, 2017
  • by Arrilot
  • Repository
  • 1 Watchers
  • 1 Stars
  • 416 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 10 Versions
  • 21 % Grown

The README.md

Latest Stable Version Total Downloads Build Status Scrutinizer Quality Score, (*1)

PHP Collectors (In development)

Introduction

Collectors scan across given fields in items/collections for ids and fetch detailed data from database or another storage, (*2)

Installation

composer require arrilot/collectors, (*3)

Usage

First of all you need to create your own collector class., (*4)


use Arrilot\Collectors\Collector; class FooCollector extends Collector { /** * Get data for given ids. * * @param array $ids * @return array */ public function getList(array $ids) { ... } }

Example, (*5)

    $elements = [
        ['id' => 1, 'files' => 1],
        ['id' => 2, 'files' => [2, 1]],
    ];

    $item = [
        'id' => 3,
        'another_files' => 3
    ];

    $collector = new FooCollector();
    $collector->scanCollection($elements, 'files');
    $collector->scanItem($item, 'another_files'); 
    // You can also pass several fields as array  - $collector->scanItem($item, ['field_1', 'field_2']);

    $files = $collector->performQuery();
    var_dump($files);

    // result
    /*
        array:2 [▼
          1 => array:3 [▼
              "id" => 1
              "name" => "avatar.png",
              "module" => "main",
          ]
          2 => array:3 [▼
              "id" => 2
              "name" => "test.png",
              "module" => "main",
          ],
          3 => array:3 [▼
               "id" => 3
               "name" => "test2.png",
               "module" => "main",
          ],
        ]
    */

You can manually add additional ids if you already know them., (*6)

$files = $collector->addIds([626, 277, 23])->performQuery();

You can pass select to getlist like that:, (*7)

$files = $collector->select(['id', 'name'])->performQuery();
// $this->select is ['id', 'name'] in `->getList()` and you can implement logic handling it.

Same is true for an additional filter., (*8)

$collector->where(['active' => 1])->performQuery();
// $this->where is ['active' => 1]

You can use dot notation to locate a field, e.g, (*9)

$collector->fromItem($item, 'properties.files');

Bridge packages

The Versions

07/12 2017

dev-master

9999999-dev https://github.com/arrilot/collectors

  Sources   Download

MIT

The Requires

 

The Development Requires

by Nekrasov Ilya

collectors

07/12 2017

0.2.3

0.2.3.0 https://github.com/arrilot/collectors

  Sources   Download

MIT

The Requires

 

The Development Requires

by Nekrasov Ilya

collectors

25/06 2017

0.2.2

0.2.2.0 https://github.com/arrilot/collectors

  Sources   Download

MIT

The Requires

 

The Development Requires

by Nekrasov Ilya

collectors

14/02 2017

0.2.1

0.2.1.0 https://github.com/arrilot/collectors

  Sources   Download

MIT

The Requires

 

The Development Requires

by Nekrasov Ilya

collectors

14/02 2017

0.2.0

0.2.0.0 https://github.com/arrilot/collectors

  Sources   Download

MIT

The Requires

 

The Development Requires

by Nekrasov Ilya

collectors

12/02 2017

0.1.4

0.1.4.0 https://github.com/arrilot/collectors

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

by Nekrasov Ilya

filler tanker

11/02 2017

0.1.3

0.1.3.0 https://github.com/arrilot/tankers

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

by Nekrasov Ilya

filler tanker

11/02 2017

0.1.2

0.1.2.0 https://github.com/arrilot/tankers

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

by Nekrasov Ilya

filler tanker

10/02 2017

0.1.1

0.1.1.0 https://github.com/arrilot/tankers

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

by Nekrasov Ilya

filler tanker

10/02 2017

0.1.0

0.1.0.0 https://github.com/arrilot/tankers

  Sources   Download

MIT

The Requires

  • php >=5.6.0

 

The Development Requires

by Nekrasov Ilya

filler tanker