public function __construct(DateFormatter $formatter = null) { if ($formatter === null) { $formatter = new DateFormatter(); } $this->dateFormatter = $formatter; }