Skip to content

Composable, reusable functions for PHP. Influenced by Ramda in the JS world.

Notifications You must be signed in to change notification settings

Joe-Withey/panda

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 

Repository files navigation

Panda

Composable, reusable, pure functions for PHP. Inspired by Ramda in the JS world. It's supposed to be a naive PHP port.

Example

<?php

require 'Panda.php';

$xs = [1, 2 ,3, [[4]], [5], 6, 8, 9];

$flattenReverseAndIncrease = P::pipe([
    P::flatten(),
    P::reverse(),
    P::map(P::inc())
]);

print_r($flattenReverseAndIncrease($xs));

Output

Array
(
    [0] => 10
    [1] => 9
    [2] => 7
    [3] => 6
    [4] => 5
    [5] => 4
    [6] => 3
    [7] => 2
)

TODO

  • Implement as a PSR-4 PHP package.
  • Consider a better way of declaring library functions.
  • Unit tests.
  • Travis.
  • Investigate performance.

Ideas

  • Create adapters for Doctrine and Laravel collections.
  • Create function implementations to work with Arrays and Objects.

Function implementations

  • [] ascend
  • identity
  • comparator
  • concat
  • contains
  • curryN
  • [] descend
  • F
  • find
  • findLast
  • flatten
  • [] groupBy
  • has
  • init
  • isEmpty
  • join
  • keys
  • [] merges?
  • omit
  • pathEq
  • pick
  • pluck
  • pathOr
  • propOr
  • reduceRight
  • reduceWhile
  • reject
  • reverse
  • [] sort
  • [] sortWith
  • split
  • splitEvery
  • splitWhen
  • T
  • [] uniq
  • [] uniqBy
  • unless
  • when
  • [] where
  • [] whereEq

About

Composable, reusable functions for PHP. Influenced by Ramda in the JS world.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages