5 ms·
For the PHP version: Why is the search method static? You are forcing whatever class you are using to be tightly coupled. Dependency injection can be done in PH
by Nycto 16y ago
For the PHP version: Why is the search method static? You are forcing whatever class you are using to be tightly coupled. Dependency injection can be done in PHP, too.
Better:
$bt = Braintree_Transaction_Search::someFactory();
$collection = $bt->search(array(
$bt->orderId()->startsWith('a2d')
$bt->customerWebsite()->endsWith('.com'),
$bt->billingFirstName()->is('John'),
$bt->status()->in(array(
Braintree_Transaction::AUTHORIZED,
Braintree_Transaction::SETTLED
)),
$bt->amount()->between('10.00', '20.00')
));
If you're really up to it, there is no reason you couldn't use an even more fluent interface in PHP...
$collection = $bt->where()
->orderId()->startsWith('a2d')
->and()->customerWebsite()->endsWith('.com')
->and()->billingFirstName()->is('John')
->search();
Also, please make sure the search method returns an iterator, not an array. Just because PHP allows you to shoot yourself in the foot, doesn't mean you should.
- TeHCrAzY 16y agoGosh, every example (even in languages I don't know) are much easier to grok than the PHP one :/