2017 © Pedro Peláez
 

library utils

Library with features that increase productivity

image

mero/utils

Library with features that increase productivity

  • Monday, June 5, 2017
  • by merorafael
  • Repository
  • 1 Watchers
  • 1 Stars
  • 205 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 10 % Grown

The README.md

Mero Utils

SensioLabsInsight Build Status Coverage Status Latest Stable Version Total Downloads License, (*1)

Library with features that increase productivity, (*2)

Instalation with composer

  1. Open your project directory;
  2. Run composer require mero/utils to add Mero Utils in your project vendor.

Type classes

Collection

Object type extended array data type with additional methods., (*3)

count()

Counts all elements in the collection., (*4)

<?php

use Mero\Utils\Collection;

$var = new Collection();
$var[] = 'First element';
$var[] = 'Second element';

$var->count(); // Will return 2
find()

Finds the first value matching the closure condition., (*5)

<?php

use Mero\Utils\Collection;

$var = new Collection([
    'First element',
    'Second element',
    1,
    4,
    10,
]);

$var->find(function($it) {
    return $it == 'Second element';
}); // Will return 'Second element'
findAll()

Finds all values matching the closure condition., (*6)

<?php

use Mero\Utils\Collection;

$var = new Collection([
    'First element',
    'Second element',
    1,
    4,
    10,
    'Second element',
    'Second element',
]);

$var->findAll(function($it) {
    return $it == 'Second element';
}); // Will return ['Second element', 'Second element', 'Second element']
collect()

Iterates through this collection transforming each entry into a new value using the transform closure returning a list of transformed values., (*7)

<?php

use Mero\Utils\Collection;

$var = new Collection([1, 2, 3]);

$var->collect(function($it) {
    return $it * 3;
}); // Will return [3, 6, 9]
each()

Iterates through an Collection, passing each item to the given closure., (*8)

<?php

use Mero\Utils\Collection;

$var = new Collection([1, 2, 3]);

$var->each(function($it) {
    echo $it."\n";
});

// Will return:
// 1
// 2
// 3
eachWithIndex()

Iterates through an Collection, passing each item to the given closure., (*9)

<?php

use Mero\Utils\Collection;

$var = new Collection(['Element1', 'Element2', 'Element3']);

$var->eachWithIndex(function($it, $index) {
    echo $index." - ".$it."\n";
});

// Will return:
// 0 - Element1
// 1 - Element2
// 2 - Element3

The Versions

05/06 2017

dev-master

9999999-dev https://github.com/merorafael/php-utils

Library with features that increase productivity

  Sources   Download

MIT

The Requires

  • php >=5.4.9

 

The Development Requires

collection utils mero

04/06 2017

0.1.0

0.1.0.0 https://github.com/merorafael/php-utils

Library with features that increase productivity

  Sources   Download

MIT

The Requires

  • php >=5.4.9

 

The Development Requires

collection utils mero