hshn/class-matcher-bundle

安装: 538

依赖项: 2

建议者: 0

安全性: 0

星级: 0

关注者: 3

分支: 0

开放问题: 0

类型:symfony-bundle

v0.1.0 2014-08-06 17:02 UTC

This package is not auto-updated.

Last update: 2024-09-24 02:18:50 UTC


README

Build Status

简化在Symfony中定义类匹配器作为服务的过程。

配置

# app/config/config.yml
hshn_class_matcher:
    matchers:
        matcher1: { equals: FooExtended }       # matches FooExtended
        matcher2: { implemented: FooInterface } # matches class that implements FooInterface
        matcher3: { extended: Foo }             # matches class that extends Foo
        matcher4: { anything: ~ }               # matches anything
        matcher5: { and: [matcher1, matcher3] } # matches class that matches matcher 'matcher1' and 'matcher3'
        matcher6: { or: [matcher1, matcher2] }  # matches class that matches matcher 'matcher1' or 'matcher2'
        matcher7: { not: matcher3 }             # matches class that do not extends Foo

用法

<?php

$provider = $container->get('hshn_class_matcher.matcher_provider');
$provider->get('matcher1')->matches('Foo'); // true or false