Happyr/Doctrine-Specification — pull request #29 by AndyBursh (2014-08-28 19:51:10+00:00)
Title: A "LIKE" specification

Nyholm, cakper

I really like your library. I've evaluated it for use at work, and it seems really easy to use and extend. Whilst using it, though, I found a couple of little things I thought were missing.

This pull request is for the first of the missing things I identified: a "like" specification. It's pretty simple and builds on your existing work with other types of comparison. I'm not sure how I feel about taking a pattern as the format and calling `sprintf($format, $value)`, but I think it works for a first iteration.

I'm also not sure about the order of the parameters. I think it'd be more readable to take the format between field and value parameters (ie `new S\Like("baz", S\Like::CONTAINS, "bing")`), but that wouldn't match the signature of the other specifications and wouldn't allow a default parameter. What do you think?

Usage example:
```php
use Happy\Doctrine\Specification\Spec as S;
// ...
$spec new S\AndX(
new S\Equals("foo", "bar"),
new S\Like("baz", "bing", S\Like::STARTS_WITH)
)
```

Regards,
Andy

P.S. Do the spec tests look OK? I've not used PHPSpec before.