getCustomers(); if (\count($customers) === 1) { $filename .= '-' . $this->convert($this->getCustomerName($customers[0])); $hasName = true; } $projects = $query->getProjects(); if (\count($projects) === 1) { if (!$hasName) { $filename .= '-' . $this->convert($this->getCustomerName($projects[0]->getCustomer())); } $filename .= '-' . $this->convert($projects[0]->getName()); $hasName = true; } $users = $query->getUsers(); if (\count($users) === 1) { $filename .= '-' . $this->convert($users[0]->getDisplayName()); $hasName = true; } if (!$hasName) { $filename .= '-kimai-export'; } $filename = str_replace(['/', '\\'], '-', $filename); $this->filename = $filename; } private function getCustomerName(Customer $customer): string { $company = $customer->getCompany(); if (empty($company)) { $company = $customer->getName(); } return $company; } private function convert(string $filename): string { return FileHelper::convertToAsciiFilename($filename); } public function getFilename() { return $this->filename; } public function __toString() { return $this->getFilename(); } }