From 23c6d0acc3c0d3f77115c574e72e39b648034211 Mon Sep 17 00:00:00 2001 From: Baptiste Fotia Date: Mon, 30 Oct 2023 10:37:28 +0100 Subject: [PATCH] chore(php): Fix php style with composer run cs:fix Signed-off-by: Baptiste Fotia --- lib/Commands/Import.php | 48 +++++++++---------- lib/Controller/WorkspaceController.php | 4 +- .../Workspace/WorkspaceCheckService.php | 6 +-- lib/Space/SpaceManager.php | 2 +- 4 files changed, 30 insertions(+), 30 deletions(-) diff --git a/lib/Commands/Import.php b/lib/Commands/Import.php index 7fccbdc69..e0c340068 100644 --- a/lib/Commands/Import.php +++ b/lib/Commands/Import.php @@ -45,11 +45,11 @@ protected function execute(InputInterface $input, OutputInterface $output): int $dataFormated = $this->csvCreatingWorkspaces->parser($path); - $spacenamesWithCharacterSpecials = $this->getWorkspacesWithCharacterSpecials($dataFormated); + $spacenamesWithCharacterSpecials = $this->getWorkspacesWithCharacterSpecials($dataFormated); - if (!is_null($spacenamesWithCharacterSpecials)) { - throw new \Exception($spacenamesWithCharacterSpecials); - } + if (!is_null($spacenamesWithCharacterSpecials)) { + throw new \Exception($spacenamesWithCharacterSpecials); + } $message = $this->getSpacenamesDuplicated($dataFormated); $message .= $this->getUsersArentExist($dataFormated); @@ -121,24 +121,24 @@ private function getUsersArentExist(array $dataResponse): ?string { return null; } - private function getWorkspacesWithCharacterSpecials(array $dataResponse): ?string { - $spacenamesWithCharacterSpecials = []; - $message = ""; - - foreach ($dataResponse as $data) { - if ($this->workspaceCheckService->containSpecialChar($data['workspace_name'])) { - $spacenamesWithCharacterSpecials[] = $data['workspace_name']; - } - } - - if (!empty($spacenamesWithCharacterSpecials)) { - $spacenamesStringify = array_map(fn ($spacename) => " - $spacename\n", $spacenamesWithCharacterSpecials); - $message .= "The workspace names below contain special characters :\n" . implode('', $spacenamesStringify); - $message .= "\nPlease, your Workspace names must not contain the following characters: " . implode(" ", str_split(WorkspaceCheckService::CHARACTERS_SPECIAL)); - - return $message; - } - - return null; - } + private function getWorkspacesWithCharacterSpecials(array $dataResponse): ?string { + $spacenamesWithCharacterSpecials = []; + $message = ""; + + foreach ($dataResponse as $data) { + if ($this->workspaceCheckService->containSpecialChar($data['workspace_name'])) { + $spacenamesWithCharacterSpecials[] = $data['workspace_name']; + } + } + + if (!empty($spacenamesWithCharacterSpecials)) { + $spacenamesStringify = array_map(fn ($spacename) => " - $spacename\n", $spacenamesWithCharacterSpecials); + $message .= "The workspace names below contain special characters :\n" . implode('', $spacenamesStringify); + $message .= "\nPlease, your Workspace names must not contain the following characters: " . implode(" ", str_split(WorkspaceCheckService::CHARACTERS_SPECIAL)); + + return $message; + } + + return null; + } } diff --git a/lib/Controller/WorkspaceController.php b/lib/Controller/WorkspaceController.php index 86f215921..52e954d95 100644 --- a/lib/Controller/WorkspaceController.php +++ b/lib/Controller/WorkspaceController.php @@ -94,7 +94,7 @@ public function createWorkspace(string $spaceName, if($this->workspaceCheck->containSpecialChar($spaceName)) { throw new BadRequestException('Your Workspace name must not contain the following characters: ' . implode(" ", str_split(WorkspaceCheckService::CHARACTERS_SPECIAL))); - } + } if ($this->workspaceCheck->isExist($spaceName)) { throw new WorkspaceNameExistException("The $spaceName space name already exist", Http::STATUS_CONFLICT); @@ -278,7 +278,7 @@ public function renameSpace(array|string $workspace, if ($this->workspaceCheck->containSpecialChar($newSpaceName)) { throw new BadRequestException('Your Workspace name must not contain the following characters: ' . implode(" ", str_split(WorkspaceCheckService::CHARACTERS_SPECIAL))); - } + } if ($newSpaceName === false || $newSpaceName === null || diff --git a/lib/Service/Workspace/WorkspaceCheckService.php b/lib/Service/Workspace/WorkspaceCheckService.php index 77e958d7b..02df9ce00 100644 --- a/lib/Service/Workspace/WorkspaceCheckService.php +++ b/lib/Service/Workspace/WorkspaceCheckService.php @@ -29,8 +29,8 @@ class WorkspaceCheckService { - public const CHARACTERS_SPECIAL = "[~<>{}|;.:,!?\'@#$+()%\\\^=\/&*\[\]]"; - + public const CHARACTERS_SPECIAL = "[~<>{}|;.:,!?\'@#$+()%\\\^=\/&*\[\]]"; + public function __construct(private SpaceService $spaceService) { } @@ -42,7 +42,7 @@ public function __construct(private SpaceService $spaceService) { */ public function containSpecialChar(string $spacename): bool { if (preg_match(sprintf("/%s/", self::CHARACTERS_SPECIAL), $spacename)) { - return true; + return true; } return false; diff --git a/lib/Space/SpaceManager.php b/lib/Space/SpaceManager.php index ead9e25ac..8ec179402 100644 --- a/lib/Space/SpaceManager.php +++ b/lib/Space/SpaceManager.php @@ -58,7 +58,7 @@ public function create(string $spacename): array { if ($this->workspaceCheck->containSpecialChar($spacename)) { throw new BadRequestException('Your Workspace name must not contain the following characters: ' . implode(" ", str_split(WorkspaceCheckService::CHARACTERS_SPECIAL))); - } + } if ($this->workspaceCheck->isExist($spacename)) { throw new WorkspaceNameExistException("The $spacename space name already exist", Http::STATUS_CONFLICT);