2017 © Pedro Peláez
 

library ra

PHP Array object with consistent and predictable API

image

wernerdweight/ra

PHP Array object with consistent and predictable API

  • Thursday, July 12, 2018
  • by wernerdweight
  • Repository
  • 1 Watchers
  • 1 Stars
  • 22 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 3 Open issues
  • 7 Versions
  • 57 % Grown

The README.md

RA

PHP Array object with consistent, predictable and convenient API, (*1)

Build Status Latest Stable Version Total Downloads License, (*2)

Instalation

1) Download using composer, (*3)

composer require wernerdweight/ra

2) Use in your project, (*4)

use WernerDweight\RA\RA;

// helper methods (extracted here to simplify the code below and emphasize the difference)

function filterFunction(string $god): bool {
    return false !== strpos($god, 's');
}

function mapFunction(string $godContainingTheLetterS): string {
    return strtoupper($godContainingTheLetterS);
}

function reduceFunction(string $carry, string $god): string {
    return $carry .= ($carry[-1] === ' ' ? '' : ', ') . $god;
}

// create new RA
$egyptianGods = new RA(['Ra', 'Osiris', 'Anubis', 'Horus']);

// use as object
$godsContainingTheLetterSInUppercase = $egyptianGods
    ->filter('filterFunction')
    ->map('mapFunction')
    ->reverse()
    ->reduce('reduceFunction', 'My favourite Egyptian Gods are ');

echo $godsContainingTheLetterSInUppercase . "\n";

// use as normal array
$godsContainingTheLetterSInUppercase = array_reduce(
    array_reverse(
        array_map(
            'mapFunction',
            array_filter(
                $egyptianGods->toArray(),
                'filterFunction'
            )
        )
    ),
    'reduceFunction',
    'My favourite Egyptian Gods are '
);

echo $godsContainingTheLetterSInUppercase . "\n";

// RA extends Iterator, ArrayAccess and Countable
foreach ($egyptianGods as $god) {
    echo sprintf("My favourite Egyptian God is %s\n", $god);
}

API

TODO:, (*5)

The Versions

12/07 2018

dev-master

9999999-dev https://github.com/wernerdweight/RA

PHP Array object with consistent and predictable API

  Sources   Download

MIT

The Requires

  • php >=7.1.0

 

The Development Requires

by Werner Dweight
by Werner Dweight Solutions

array object iterable

12/07 2018

v0.2.0

0.2.0.0 https://github.com/wernerdweight/RA

PHP Array object with consistent and predictable API

  Sources   Download

MIT

The Requires

  • php >=7.1.0

 

The Development Requires

by Werner Dweight Solutions

array object iterable

12/07 2018

dev-feature/tests-and-coding-standards

dev-feature/tests-and-coding-standards https://github.com/wernerdweight/RA

PHP Array object with consistent and predictable API

  Sources   Download

MIT

The Requires

  • php >=7.1.0

 

The Development Requires

by Werner Dweight Solutions

array object iterable

10/05 2018

v0.1.1

0.1.1.0 https://github.com/wernerdweight/RA

PHP Array object with consistent and predictable API

  Sources   Download

MIT

The Requires

  • php >=7.1.0

 

by Werner Dweight

array object iterable

20/03 2018

v0.1.0

0.1.0.0 https://github.com/wernerdweight/RA

PHP Array object with consistent and predictable API

  Sources   Download

MIT

The Requires

  • php >=7.1.0

 

by Werner Dweight

array object iterable

18/03 2018

v0.0.2

0.0.2.0 https://github.com/wernerdweight/RA

PHP Array object with consistent and predictable API

  Sources   Download

MIT

The Requires

  • php >=7.1.0

 

by Werner Dweight

array object iterable

17/03 2018

v0.0.1

0.0.1.0 https://github.com/wernerdweight/RA

PHP Array object with consistent and predictable API

  Sources   Download

MIT

The Requires

  • php >=7.1.0

 

by Werner Dweight

array object iterable