Skip to content

Commit

Permalink
code style
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinpapst committed Aug 4, 2024
1 parent 20d6915 commit 595201f
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 36 deletions.
48 changes: 24 additions & 24 deletions Command/KimaiImporterCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$this->activities = [];
}

$io->title(sprintf('Handling data from table prefix: %s', $this->dbPrefix));
$io->title(\sprintf('Handling data from table prefix: %s', $this->dbPrefix));

if ($options['fix-email'] !== null) {
$io->text('Fixing email addresses');
Expand Down Expand Up @@ -501,23 +501,23 @@ private function validateKimai1Data(array $options, array $users, array $custome
foreach ($users as $oldUser) {
$userIds[] = $oldUser['userID'];
if (empty($oldUser['mail'])) {
$validationMessages[] = sprintf(
$validationMessages[] = \sprintf(
'User "%s" with ID %s has no email',
$oldUser['name'],
$oldUser['userID']
);
continue;
}
if (\in_array($oldUser['mail'], $usedEmails)) {
$validationMessages[] = sprintf(
$validationMessages[] = \sprintf(
'Email "%s" for user "%s" with ID %s is already used',
$oldUser['mail'],
$oldUser['name'],
$oldUser['userID']
);
}
if ($this->options['alias-as-account-number'] && mb_strlen($oldUser['alias']) > 30) {
$validationMessages[] = sprintf(
$validationMessages[] = \sprintf(
'Alias "%s" for user "%s" with ID %s, which should be used as account number, is longer than 30 character',
$oldUser['alias'],
$oldUser['name'],
Expand All @@ -531,7 +531,7 @@ private function validateKimai1Data(array $options, array $users, array $custome
foreach ($customer as $oldCustomer) {
$customerIds[] = $oldCustomer['customerID'];
if (($customerNameLength = mb_strlen($oldCustomer['name'])) > 150) {
$validationMessages[] = sprintf(
$validationMessages[] = \sprintf(
'Customer name "%s" (ID %s) is too long. Max. 150 character are allowed, found %s.',
$oldCustomer['name'],
$oldCustomer['customerID'],
Expand All @@ -542,15 +542,15 @@ private function validateKimai1Data(array $options, array $users, array $custome

foreach ($projects as $oldProject) {
if (!\in_array($oldProject['customerID'], $customerIds)) {
$validationMessages[] = sprintf(
$validationMessages[] = \sprintf(
'Project "%s" with ID %s has unknown customer with ID %s',
$oldProject['name'],
$oldProject['projectID'],
$oldProject['customerID']
);
}
if (($projectNameLength = mb_strlen($oldProject['name'])) > 150) {
$validationMessages[] = sprintf(
$validationMessages[] = \sprintf(
'Project name "%s" (ID %s) is too long. Max. 150 character are allowed, found %s.',
$oldProject['name'],
$oldProject['projectID'],
Expand All @@ -561,7 +561,7 @@ private function validateKimai1Data(array $options, array $users, array $custome

foreach ($activities as $oldActivity) {
if (($activityNameLength = mb_strlen($oldActivity['name'])) > 150) {
$validationMessages[] = sprintf(
$validationMessages[] = \sprintf(
'Activity name "%s" (ID %s) is too long. Max. 150 character are allowed, found %s.',
$oldActivity['name'],
$oldActivity['activityID'],
Expand All @@ -576,7 +576,7 @@ private function validateKimai1Data(array $options, array $users, array $custome
continue;
}
if (!\in_array($oldRate['userID'], $userIds)) {
$validationMessages[] = sprintf(
$validationMessages[] = \sprintf(
'Unknown user with ID "%s" found for rate with project "%s" and activity "%s"',
$oldRate['userID'],
$oldRate['projectID'],
Expand Down Expand Up @@ -608,7 +608,7 @@ private function checkDatabaseVersion(Connection $connection, SymfonyStyle $io):
->executeQuery();
} catch (Exception $e) {
$io->error(
sprintf('Cannot read from table "%sconfiguration", make sure that your prefix "%s" is correct.', $this->dbPrefix, $this->dbPrefix)
\sprintf('Cannot read from table "%sconfiguration", make sure that your prefix "%s" is correct.', $this->dbPrefix, $this->dbPrefix)
);

return false;
Expand Down Expand Up @@ -819,7 +819,7 @@ private function isKnownUser(SymfonyStyle $io, array $oldUser): bool
continue;
}
if ($newEmail === $oldEmail && $newName !== $oldName) {
$io->warning(sprintf(
$io->warning(\sprintf(
'Found problematic user combination. Username matches, but email does not. Cached user: ID %s, %s, %s. New user: ID %s, %s, %s.',
$tmpUser->getId(),
$newEmail,
Expand All @@ -830,7 +830,7 @@ private function isKnownUser(SymfonyStyle $io, array $oldUser): bool
));
}
if ($newEmail !== $oldEmail && $newName === $oldName) {
$io->warning(sprintf(
$io->warning(\sprintf(
'Found problematic user combination. Emails matches, but username does not. Cached user: ID %s, %s, %s. New user: ID %s, %s, %s.',
$tmpUser->getId(),
$newEmail,
Expand Down Expand Up @@ -1167,7 +1167,7 @@ private function importProjects(SymfonyStyle $io, array $projects, array $fixedR
$customer = $this->getCachedCustomer($oldProject['customerID']);
if ($customer === null) {
$io->error(
sprintf('Found project with unknown customer. Project ID: "%s", Name: "%s", Customer ID: "%s"', $oldProject['projectID'], $oldProject['name'], $oldProject['customerID'])
\sprintf('Found project with unknown customer. Project ID: "%s", Name: "%s", Customer ID: "%s"', $oldProject['projectID'], $oldProject['name'], $oldProject['customerID'])
);
continue;
}
Expand Down Expand Up @@ -1224,7 +1224,7 @@ private function importProjects(SymfonyStyle $io, array $projects, array $fixedR
$io->success('Created fixed project rate: ' . $project->getName() . ' for customer: ' . $customer->getName());
}
} catch (Exception $ex) {
$io->error(sprintf('Failed to create fixed project rate for %s: %s' . $project->getName(), $ex->getMessage()));
$io->error(\sprintf('Failed to create fixed project rate for %s: %s' . $project->getName(), $ex->getMessage()));
}
}
}
Expand All @@ -1248,7 +1248,7 @@ private function importProjects(SymfonyStyle $io, array $projects, array $fixedR
$io->success('Created project rate: ' . $project->getName() . ' for customer: ' . $customer->getName());
}
} catch (Exception $ex) {
$io->error(sprintf('Failed to create project rate for %s: %s' . $project->getName(), $ex->getMessage()));
$io->error(\sprintf('Failed to create project rate for %s: %s' . $project->getName(), $ex->getMessage()));
}
}
}
Expand Down Expand Up @@ -1468,7 +1468,7 @@ private function createActivity(
$project = $this->getCachedProject($oldProjectId);
if ($project === null) {
throw new Exception(
sprintf(
\sprintf(
'Did not find project [%s], skipping activity creation [%s] %s',
$oldProjectId,
$oldActivityId,
Expand Down Expand Up @@ -1522,7 +1522,7 @@ private function createActivity(
$io->success('Created fixed activity rate: ' . $activity->getName());
}
} catch (Exception $ex) {
$io->error(sprintf('Failed to create fixed activity rate for %s: %s' . $activity->getName(), $ex->getMessage()));
$io->error(\sprintf('Failed to create fixed activity rate for %s: %s' . $activity->getName(), $ex->getMessage()));
}
}
}
Expand Down Expand Up @@ -1550,7 +1550,7 @@ private function createActivity(
$io->success('Created activity rate: ' . $activity->getName());
}
} catch (Exception $ex) {
$io->error(sprintf('Failed to create activity rate for %s: %s' . $activity->getName(), $ex->getMessage()));
$io->error(\sprintf('Failed to create activity rate for %s: %s' . $activity->getName(), $ex->getMessage()));
}
}
}
Expand Down Expand Up @@ -1809,7 +1809,7 @@ private function importTimesheetRecords(OutputInterface $output, SymfonyStyle $i
$io->error('Found invalid mapped project - activity combinations in these old timesheet recors: ' . implode(',', $errors['projectActivityMismatch']));
}
if ($failed > 0) {
$io->error(sprintf('Failed importing %s timesheet records', $failed));
$io->error(\sprintf('Failed importing %s timesheet records', $failed));
}

return $counter;
Expand Down Expand Up @@ -1910,7 +1910,7 @@ private function importGroups(SymfonyStyle $io): int
// create teams just with names of groups
foreach ($groups as $group) {
if ($group['trash'] === 1) {
$io->warning(sprintf('Skipping team "%s" because it is trashed.', $group['name']));
$io->warning(\sprintf('Skipping team "%s" because it is trashed.', $group['name']));
$skippedTrashed++;
continue;
}
Expand Down Expand Up @@ -1954,7 +1954,7 @@ private function importGroups(SymfonyStyle $io): int
// if team has no users it will not be persisted
foreach ($newTeams as $oldId => $team) {
if (!$team->hasUsers()) {
$io->warning(sprintf('Didn\'t import team: %s because it has no users.', $team->getName()));
$io->warning(\sprintf('Didn\'t import team: %s because it has no users.', $team->getName()));
++$skippedEmpty;
unset($newTeams[$oldId]);
}
Expand Down Expand Up @@ -2031,7 +2031,7 @@ private function importGroups(SymfonyStyle $io): int
$entityManager->persist($team);
if ($this->debug) {
$io->success(
sprintf(
\sprintf(
'Created team: %s with %s users, %s projects and %s customers.',
$team->getName(),
\count($team->getUsers()),
Expand Down Expand Up @@ -2089,7 +2089,7 @@ private function fixEmail(string $domain): void
{
$query = $this->connection->createQueryBuilder()
->update($this->dbPrefix . 'users')
->set('mail', sprintf('CONCAT(LOWER(name), "_import@%s")', $domain))
->set('mail', \sprintf('CONCAT(LOWER(name), "_import@%s")', $domain))
->where("mail = '' OR mail IS null")
;
$query->executeStatement();
Expand Down Expand Up @@ -2148,7 +2148,7 @@ private function fixEncoding(): void
foreach ($searchReplace as $search => $replace) {
$query = $this->connection->createQueryBuilder()
->update($this->dbPrefix . $table, $this->dbPrefix . $table)
->set($column, sprintf('REPLACE(%s, "%s", "%s")', $column, $search, $replace))
->set($column, \sprintf('REPLACE(%s, "%s", "%s")', $column, $search, $replace))
->where($column . ' LIKE "%' . $search . '%"')
;
$query->executeStatement();
Expand Down
16 changes: 8 additions & 8 deletions Importer/AbstractTimesheetImporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function importRow(Duration $durationParser, ImportData $data, ImportRow

if (null === ($user = $this->getUser($record['User'], $record['Email'], $dryRun))) {
throw new ImportException(
sprintf('Unknown user %s', $record['User'])
\sprintf('Unknown user %s', $record['User'])
);
}

Expand Down Expand Up @@ -229,25 +229,25 @@ public function import(ImportModelInterface $model, array $rows): ImportData
}

if ($data->countRows() > 0) {
$data->addStatus(sprintf('processed %s rows', $data->countRows()));
$data->addStatus(\sprintf('processed %s rows', $data->countRows()));
}
if ($data->countErrors() > 0) {
$data->addStatus(sprintf('failed %s rows', $data->countErrors()));
$data->addStatus(\sprintf('failed %s rows', $data->countErrors()));
}
if ($this->createdCustomers > 0) {
$data->addStatus(sprintf('%s %s customers', $create, $this->createdCustomers));
$data->addStatus(\sprintf('%s %s customers', $create, $this->createdCustomers));
}
if ($this->createdProjects > 0) {
$data->addStatus(sprintf('%s %s projects', $create, $this->createdProjects));
$data->addStatus(\sprintf('%s %s projects', $create, $this->createdProjects));
}
if ($this->createdActivities > 0) {
$data->addStatus(sprintf('%s %s activities', $create, $this->createdActivities));
$data->addStatus(\sprintf('%s %s activities', $create, $this->createdActivities));
}
if ($this->createdTags > 0) {
$data->addStatus(sprintf('%s %s tags', $create, $this->createdTags));
$data->addStatus(\sprintf('%s %s tags', $create, $this->createdTags));
}
if ($this->createdUsers > 0) {
$data->addStatus(sprintf('%s %s users', $create, $this->createdUsers));
$data->addStatus(\sprintf('%s %s users', $create, $this->createdUsers));
}

return $data;
Expand Down
2 changes: 1 addition & 1 deletion Importer/CustomerImporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public function import(ImportModelInterface $model, array $rows): ImportData
}

if ($createdCustomers > 0) {
$data->addStatus(sprintf('created %s customers', $createdCustomers));
$data->addStatus(\sprintf('created %s customers', $createdCustomers));
}

return $data;
Expand Down
2 changes: 1 addition & 1 deletion Importer/GrandtotalCustomerImporter.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public function import(ImportModelInterface $model, array $rows): ImportData
}

if ($createdCustomers > 0) {
$data->addStatus(sprintf('created %s customers', $createdCustomers));
$data->addStatus(\sprintf('created %s customers', $createdCustomers));
}

return $data;
Expand Down
4 changes: 2 additions & 2 deletions Importer/ImporterService.php
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public function import(ImportModel $model, string $importer): ImportData
}

throw new ImportException(
sprintf('Unsupported file given, invalid mimetype (%s / %s). Try to use another browser.', $mimetype, $userMimetype)
\sprintf('Unsupported file given, invalid mimetype (%s / %s). Try to use another browser.', $mimetype, $userMimetype)
);
}

Expand Down Expand Up @@ -176,7 +176,7 @@ private function importCsv(ImportModel $model, string $import): ImportData
}

if (\count($header) === 1 && stripos($header[0], $oppositeDelimiter) !== false) {
throw new ImportException(sprintf('Unsupported file given: retry with the "%s" delimiter', $oppositeDelimiter));
throw new ImportException(\sprintf('Unsupported file given: retry with the "%s" delimiter', $oppositeDelimiter));
}

if ($csv->count() > self::MAX_ROWS) {
Expand Down

0 comments on commit 595201f

Please sign in to comment.