2017 © Pedro Peláez
 

library php-pipeline

Compose many callables into a single callable.

image

samueldavis/php-pipeline

Compose many callables into a single callable.

  • Wednesday, July 19, 2017
  • by Riffian51
  • Repository
  • 0 Watchers
  • 0 Stars
  • 3 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

PhpPipeline

Hilarious implementation of chainable callable calls., (*1)

https://github.com/thephpleague/pipeline is much more appropriate, but this is pretty cool too. I appreciate how the state isn't obscured because the thing itself is the state., (*2)

Example Usage

class Remover
{
    public static function pop(array $arr = [])
    {
        return array_pop($arr);
    }
}

$stringHelper = new class
{
    public function concat(string $initial, string $addition): string
    {
        return $initial . $addition;
    }
};

$explodeCurry = function (string $string) {
    return explode(' ', $string);
};

$explodingPipeline = (new Pipe)
    ->into('strtoupper')
    ->into($explodeCurry);

$getResult = (new Pipe('foo bar'))
    ->into($explodingPipeline)
    ->into([Remover::class, 'pop'])
    ->into([$stringHelper, 'concat'], 'fiz');

var_dump($getResult());
echo "========\n" . json_encode($getResult, JSON_PRETTY_PRINT);
~/code/pipe/example.php:33:
string(6) "BARfiz"
========
{
    "0": "foo bar",
    "1": [
        {
            "0": null,
            "1": [
                "strtoupper"
            ],
            "2": [
                {}
            ]
        }
    ],
    "2": [
        [
            "Remover",
            "pop"
        ]
    ],
    "3": [
        [
            {},
            "concat"
        ],
        "fiz"
    ]
}

The Versions

19/07 2017

dev-master

9999999-dev

Compose many callables into a single callable.

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

by Samuel Davis

19/07 2017

1.0.1

1.0.1.0

Compose many callables into a single callable.

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

by Samuel Davis

21/02 2017

1.0.0

1.0.0.0

Compose many callables into a single callable.

  Sources   Download

MIT

The Requires

  • php ^7.0

 

The Development Requires

by Samuel Davis

21/02 2017

dev-return_many

dev-return_many

  Sources   Download

MIT

by Samuel Davis