Skip to content

Commit

Permalink
chore(php): Fix php style with composer run cs:fix
Browse files Browse the repository at this point in the history
Signed-off-by: Baptiste Fotia <[email protected]>
  • Loading branch information
zak39 committed Oct 30, 2023
1 parent d19781b commit 23c6d0a
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 30 deletions.
48 changes: 24 additions & 24 deletions lib/Commands/Import.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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;
}
}
4 changes: 2 additions & 2 deletions lib/Controller/WorkspaceController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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 ||
Expand Down
6 changes: 3 additions & 3 deletions lib/Service/Workspace/WorkspaceCheckService.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@

class WorkspaceCheckService {

public const CHARACTERS_SPECIAL = "[~<>{}|;.:,!?\'@#$+()%\\\^=\/&*\[\]]";
public const CHARACTERS_SPECIAL = "[~<>{}|;.:,!?\'@#$+()%\\\^=\/&*\[\]]";
public function __construct(private SpaceService $spaceService) {
}

Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion lib/Space/SpaceManager.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 23c6d0a

Please sign in to comment.