boyhagemann / matcher
此软件包最新版本(dev-master)没有提供许可证信息。
dev-master
2014-01-02 15:09 UTC
Requires
- php: >=5.3.0
- illuminate/support: 4.0.x
This package is not auto-updated.
Last update: 2024-09-24 07:17:04 UTC
README
使用Matcher,您可以根据指定的规则匹配对象并返回数据。
示例用法
// 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'))"
规则逻辑
每个规则都可以使用不同的逻辑进行匹配。目前,已实现的逻辑有
// 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');
文档将在以下方面更新
- 使用标签
- 唯一字段
- 匹配逻辑说明
- 匹配多个值
- 设置默认值
- 当您可以使用此库的实用场景