2017 © Pedro Peláez
 

library matcher

image

boyhagemann/matcher

  • Thursday, January 2, 2014
  • by boyhagemann
  • Repository
  • 1 Watchers
  • 0 Stars
  • 0 Installations
  • PHP
  • 1 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Matcher

With Matcher you can match an object to specified rules and get data returned., (*1)

Example usage

// Add some rules
$matcher->whenProperty('title')->contains('Hi')->provide(['foo' => 'bar']);

// Get an object to match against
$object = Your\Object;
$object->title = 'Hi';

// Check if the object matches the rules
$data = $matcher->match($object); // Will return "array(array('foo' => 'bar'))"

Rule logic

Every rule can match using different logics. For now, these are the implemented logics:, (*2)

// Applied the a Rule object
$rule->equals('foo'); // Default logic
$rule->startsWith('foo');
$rule->endsWith('foo');
$rule->contains('foo');

//Applied to a Container object using the fluent interface
$matcher->whenProperty('title')->equals('foo');
$matcher->whenProperty('title')->startsWith('foo');
$matcher->whenProperty('title')->endsWith('foo');
$matcher->whenProperty('title')->contains('foo');

Documentation will be updated with: * Using tags * Unique fields * Match logic explained * Match against multiple values * Setting default values * Helpful scenarios when you can use this library, (*3)

The Versions

02/01 2014

dev-master

9999999-dev

  Sources   Download

The Requires

 

by Boy Hagemann