serafim/placeholder

Simple placeholder implementation for functional constructions

1.0.0 2019-07-04 19:24 UTC

README

Placeholder

Travis CI 68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f31323266316661633633623662356132363131372f746573745f636f766572616765 68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f31323266316661633633623662356132363131372f6d61696e7461696e6162696c697479

PHP 7.1+ Latest Stable Version Total Downloads License MIT

Library provides a placeholder implementation for currying functions, partial applications, pipe operator, and other syntactic structures hat allow specifying default values.

Usage

What is "placeholder"?

<?php

var_dump(is_placeholder('_'));
// expected output: false

var_dump(is_placeholder(_));
// expected output: true

For example we can replace each of the placeholders in the array with the required value.

<?php
use Serafim\Placeholder\Placeholder;

$array = [1, _, 3, _];

$result = Placeholder::map($array, fn() => ' map ');

echo implode(', ', $result);

// expected output: "1, map, 3, map"

And... Thats all =)