private function setDate($data, $key, $defaultDate, callable $setCallback)
    {
        $date = $this->getProperty($data, $key, $defaultDate);

        if ($date !== null) {
            // set to null if empty
            if (empty($date)) {
                $date = null;
            }
            if (is_string($date)) {
                $date = new \DateTime($date);
            }
            // call the given set date function
            call_user_func($setCallback, $date);
        }
    }