If I have a DateRange class, and I want to translate a DateRange into SQL (e.g. some_col >= '2015-3-5' AND some_col <= '2015-3-5'), where should I put the method that does the translating? Nothing I've come up so far with seems very good.
Option #1: Put a method in the DateRange class. (Downside: close coupling of the DateRange class and SQL?)
class DateRange {
public function toSQL ($colName) {...}
}
Opton #2: Make a class that only has one method in it?
class DateRangeTranslator {...}
I'm leaning towards option 2. But is there a better way?