Skip to content

Commit

Permalink
fix(tests): Fix PHP CS tests
Browse files Browse the repository at this point in the history
  • Loading branch information
maximehuran committed Jan 21, 2025
1 parent b7ba783 commit 1b09afc
Show file tree
Hide file tree
Showing 13 changed files with 15 additions and 15 deletions.
2 changes: 1 addition & 1 deletion src/Exception/CannotReadCurrentFolderException.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ final class CannotReadCurrentFolderException extends Exception
public function __construct(string $path)
{
$this->path = $path;
parent::__construct(sprintf('Current folder cannot be opened `%s`', $path));
parent::__construct(\sprintf('Current folder cannot be opened `%s`', $path));
}

public function getPath(): string
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/CannotReadFolderException.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ final class CannotReadFolderException extends Exception
public function __construct(string $path)
{
$this->path = $path;
parent::__construct(sprintf('Folder cannot be opened `%s`', $path));
parent::__construct(\sprintf('Folder cannot be opened `%s`', $path));
}

public function getPath(): string
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/FileNotCreatedException.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function __construct(string $filename, string $errorMessage)
{
$this->filename = $filename;
$this->errorMessage = $errorMessage;
parent::__construct(sprintf('File `%s` couldn\'t be created. Error : %s', $filename, $errorMessage));
parent::__construct(\sprintf('File `%s` couldn\'t be created. Error : %s', $filename, $errorMessage));
}

public function getFilename(): string
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/FileNotDeletedException.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ final class FileNotDeletedException extends Exception
public function __construct(string $filename)
{
$this->filename = $filename;
parent::__construct(sprintf('File `%s` couldn\'t be deleted', $filename));
parent::__construct(\sprintf('File `%s` couldn\'t be deleted', $filename));
}

public function getFilename(): string
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/FileNotFoundException.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ final class FileNotFoundException extends Exception
public function __construct(string $path)
{
$this->path = $path;
parent::__construct(sprintf('File not found `%s`', $path));
parent::__construct(\sprintf('File not found `%s`', $path));
}

public function getPath(): string
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/FileTooBigException.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public function __construct(string $filename, int $size, int $maxAllowedSizeByte
$this->maxAllowedSizeBytes = $maxAllowedSizeBytes;
$this->maxAllowedSize = $maxAllowedSize;
parent::__construct(
sprintf(
\sprintf(
'File `%s` couldn\'t be created. File size %s is bigger than %s bytes. (%s)',
$filename,
$size,
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/FolderNotCreatedException.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ final class FolderNotCreatedException extends Exception
public function __construct(string $folder)
{
$this->folder = $folder;
parent::__construct(sprintf('Folder `%s` couldn\'t be created', $folder));
parent::__construct(\sprintf('Folder `%s` couldn\'t be created', $folder));
}

public function getFolder(): string
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/FolderNotDeletedException.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ final class FolderNotDeletedException extends Exception
public function __construct(string $folder)
{
$this->folder = $folder;
parent::__construct(sprintf('Folder `%s` couldn\'t be deleted', $folder));
parent::__construct(\sprintf('Folder `%s` couldn\'t be deleted', $folder));
}

public function getFolder(): string
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/FolderNotRenamedException.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ final class FolderNotRenamedException extends Exception
public function __construct(string $folder)
{
$this->folder = $folder;
parent::__construct(sprintf('Folder `%s` couldn\'t be renamed', $folder));
parent::__construct(\sprintf('Folder `%s` couldn\'t be renamed', $folder));
}

public function getFolder(): string
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/InvalidMimeTypeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function __construct(array $allowedMimeTypes, string $mimeType)
$this->allowedMimeTypes = $allowedMimeTypes;
$this->mimeType = $mimeType;

parent::__construct(sprintf(
parent::__construct(\sprintf(
'Invalid mime type. Excepted one of %s, `%s` given',
implode(', ', $allowedMimeTypes),
$mimeType
Expand Down
2 changes: 1 addition & 1 deletion src/Exception/InvalidTypeException.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function __construct(string $type, array $allowedTypes)
$this->type = $type;
$this->allowedTypes = $allowedTypes;

parent::__construct(sprintf('Invalid type `%s`, allowed types : %s', $type, implode(', ', $allowedTypes)));
parent::__construct(\sprintf('Invalid type `%s`, allowed types : %s', $type, implode(', ', $allowedTypes)));
}

public function getType(): string
Expand Down
4 changes: 2 additions & 2 deletions src/Helper/FileHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -208,11 +208,11 @@ public function upload(UploadedFile $file, string $path, ?string $folder = null)
$fileName = mb_strtolower($fileName, 'UTF-8');

// Build final path and loop if the file already exists
$finalName = sprintf('%s.%s', $fileName, $extension);
$finalName = \sprintf('%s.%s', $fileName, $extension);
$filePath = $this->getFullPath($path) . '/' . $finalName;
$count = 1;
while (file_exists($filePath)) {
$finalName = sprintf('%s_%d.%s', $fileName, $count++, $extension);
$finalName = \sprintf('%s_%d.%s', $fileName, $count++, $extension);
$filePath = $this->getFullPath($path) . '/' . $finalName;
}

Expand Down
4 changes: 2 additions & 2 deletions src/Twig/Extension/FilterExtensionDecorator.php
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ public function filter(
$dataRoots = $this->loaders['default']['filesystem']['data_root'] ?? ['/media/image/'];

foreach (array_unique($dataRoots) as $imagePath) {
if (!$this->canImageBeFiltered($path) && file_exists(sprintf('%s/%s', $imagePath, $path))) {
return str_replace($this->publicDir, '', sprintf('%s/%s', $imagePath, $path));
if (!$this->canImageBeFiltered($path) && file_exists(\sprintf('%s/%s', $imagePath, $path))) {
return str_replace($this->publicDir, '', \sprintf('%s/%s', $imagePath, $path));
}
}

Expand Down

0 comments on commit 1b09afc

Please sign in to comment.