2017 © Pedro Peláez
 

library match

pattern matching for php

image

zweifisch/match

pattern matching for php

  • Tuesday, September 3, 2013
  • by zf
  • Repository
  • 1 Watchers
  • 8 Stars
  • 16 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 4 Versions
  • 0 % Grown

The README.md

match Build Status

pattern matching for php, (*1)

install via composer, (*2)

composer require 'zweifisch/match:*'

destruct value, (*3)

$array = [1,[2,[3,4]]];
extract(\match\destruct(['a',['b',['c','d']]], $array)) or die("match failed");
echo "$a $b $c $d"; // "1 2 3 4"

passing to a function, (*4)

$input = ['method'=>'foo', 'params'=>['bar']];
$pattern = ['method'=>'func', 'params'=>['arg1']];
$result = \match\let($pattern, $input, function($arg1, $func){
    return "$func $arg1";
});
// "foo bar"

destruct multiple values, (*5)

$input = ['method'=>'foo', 'params'=>['bar']];
$result = \match\let(
    ['method'=>'func', 'params'=>['arg1']], $input
    'now', time(),
    function($func, $arg1, $now){
        return "$func $arg1 $now";
    }
);

tests

composer install --dev
vendor/bin/phpunit -c tests

The Versions

03/09 2013

dev-master

9999999-dev https://github.com/zweifisch/php-pattern-matching

pattern matching for php

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Feng Zhou

pattern-matching

03/09 2013

v0.0.3

0.0.3.0 https://github.com/zweifisch/php-pattern-matching

pattern matching for php

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Feng Zhou

pattern-matching

22/06 2013

v0.0.2

0.0.2.0 https://github.com/zweifisch/php-pattern-matching

pattern matching for php

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Feng Zhou

pattern-matching

22/06 2013

v0.0.1

0.0.1.0 https://github.com/zweifisch/php-pattern-matching

pattern matching for php

  Sources   Download

MIT

The Requires

  • php >=5.4.0

 

The Development Requires

by Feng Zhou

pattern-matching