Article-related methods such as articleList and editionLatest and well as subscriptionList are starting to have significantly complex input; using method parameters would be a mess, and using a data array as update methods do would be fraught with bugs, not to mention awkward syntax.
The best way to address this may be to introduce a Context class which the caller can build and the called method then inspect with less pain than an associative array. Building the context might go something like this:
$context=(newContext)->folder(4)// only articles/subscriptions within folder #4
->subscription(5)// only articles within subscription #5
->feed(10)// only articles within feed #10
->latestEdition(394)// only articles equal or less than edition #394
->oldestEdition(394)// only articles newer than edition #394
->modifiedSince($time)// only articles newer than a given time
->modifiedBefore($time)// only articles equal or older than a given time
->unread(true)// only unread articles
->read(true)// only read articles
->starred(true)//only starred articles
->unstarred(true)// only unstarred articles
->limit(5)// return no more than 5
->offset(10)//skip the first 10 results
->reversed(true);// return results in inverse order from whatever is usual
Obviously not all constraints will make sense for a given query. The method in question would probably have to handle each constraint separately regardless because the query would need to be constructed differently for different selection aims; the Context class should make this handling as painless as possible, however.
Article-related methods such as `articleList` and `editionLatest` and well as `subscriptionList` are starting to have significantly complex input; using method parameters would be a mess, and using a data array as update methods do would be fraught with bugs, not to mention awkward syntax.
The best way to address this may be to introduce a `Context` class which the caller can build and the called method then inspect with less pain than an associative array. Building the context might go something like this:
```php
$context = (new Context)
->folder(4) // only articles/subscriptions within folder #4
->subscription(5) // only articles within subscription #5
->feed(10) // only articles within feed #10
->latestEdition(394) // only articles equal or less than edition #394
->oldestEdition(394) // only articles newer than edition #394
->modifiedSince($time) // only articles newer than a given time
->modifiedBefore($time) // only articles equal or older than a given time
->unread(true) // only unread articles
->read(true) // only read articles
->starred(true) //only starred articles
->unstarred(true) // only unstarred articles
->limit(5) // return no more than 5
->offset(10) //skip the first 10 results
->reversed(true); // return results in inverse order from whatever is usual
```
Obviously not all constraints will make sense for a given query. The method in question would probably have to handle each constraint separately regardless because the query would need to be constructed differently for different selection aims; the `Context` class should make this handling as painless as possible, however.
Article-related methods such as
articleList
andeditionLatest
and well assubscriptionList
are starting to have significantly complex input; using method parameters would be a mess, and using a data array as update methods do would be fraught with bugs, not to mention awkward syntax.The best way to address this may be to introduce a
Context
class which the caller can build and the called method then inspect with less pain than an associative array. Building the context might go something like this:Obviously not all constraints will make sense for a given query. The method in question would probably have to handle each constraint separately regardless because the query would need to be constructed differently for different selection aims; the
Context
class should make this handling as painless as possible, however.