diffInMonths($end) > 12) { $period = 'MultiYear'; } // more than two months date difference means year report. if ($start->diffInMonths($end) > 1) { $period = 'Year'; } $class = sprintf('FireflyIII\Generator\Report\%s\%sReportGenerator', $type, $period); if (class_exists($class)) { /** @var ReportGeneratorInterface $obj */ $obj = new $class; $obj->setStartDate($start); $obj->setEndDate($end); return $obj; } throw new FireflyException(sprintf('Class "%s" does not exist.', $class)); } }