/** * @param Marriage $marriage * @return boolean|Marriage Marriage used as boolean. If it matches the conditions. */ public function isSatisfiedBy($marriage) { $marriages = $marriage->getMarriages(); foreach ($marriages as $marriageEvent) { // if both of these are not true (it is before the start OR after the end) if ($marriageEvent->occurredOn < $start || $mariageEvent->occurredOn > $end) { return false; } } return $marriage; }