Skip to content

Commit

Permalink
coding style fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
clash82 committed Aug 23, 2024
1 parent 5729026 commit 9ce840c
Show file tree
Hide file tree
Showing 26 changed files with 52 additions and 52 deletions.
8 changes: 4 additions & 4 deletions src/Command/RebuildImagesCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,13 @@ protected function execute(InputInterface $input, OutputInterface $output): int
/** @var string $slug */
$slug = $input->getArgument('album');

$output->writeln(sprintf('Selected album: <comment>%s</comment>', $slug));
$output->writeln(\sprintf('Selected album: <comment>%s</comment>', $slug));
$output->writeln('');

try {
$this->imageConverter->setAlbum($this->albumProvider->getBySlug($slug));
} catch (AlbumSettingsNotFoundException) {
$output->writeln(sprintf('<error>`%s` album was not found</error>', $slug));
$output->writeln(\sprintf('<error>`%s` album was not found</error>', $slug));

return 1;
}
Expand All @@ -63,14 +63,14 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$files = $item->getImages();

foreach ($files as $file) {
$output->writeln(sprintf('Converting (<comment>%d</comment>): <info>%s</info>', ++$processedCounter, $file));
$output->writeln(\sprintf('Converting (<comment>%d</comment>): <info>%s</info>', ++$processedCounter, $file));
/* @noinspection PhpUnhandledExceptionInspection */
$this->imageConverter->convert($file);
}
}

$output->writeln('');
$output->writeln(sprintf('Done, <comment>%d</comment> images processed.', $processedCounter));
$output->writeln(\sprintf('Done, <comment>%d</comment> images processed.', $processedCounter));

return 0;
}
Expand Down
4 changes: 2 additions & 2 deletions src/Controller/AlbumController.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public function index(int $page): Response
);

/* @noinspection PhpUnhandledExceptionInspection */
return $this->render(sprintf('album/%s/index.html.twig', $album->getSlug()), [
return $this->render(\sprintf('album/%s/index.html.twig', $album->getSlug()), [
'items' => $items,
'album' => $this->albumProvider->getBySlug($album->getSlug()),
]);
Expand All @@ -58,7 +58,7 @@ public function item(string $itemSlug): Response
$this->counterHelper->increment($album->getSlug());

/* @noinspection PhpUnhandledExceptionInspection */
return $this->render(sprintf('album/%s/item.html.twig', $album->getSlug()), [
return $this->render(\sprintf('album/%s/item.html.twig', $album->getSlug()), [
'item' => $item,
'next_item' => $this->itemProvider->getNext($item),
'prev_item' => $this->itemProvider->getPrevious($item),
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/Helper/CounterHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function __construct(ParameterBagInterface $parameterBag)
}

// this file is hosted only on my server
$wrapperFile = sprintf('%s/../../include/wrappers/counter.php', getcwd());
$wrapperFile = \sprintf('%s/../../include/wrappers/counter.php', getcwd());

if (file_exists($wrapperFile)) {
/* @noinspection PhpIncludeInspection */
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/Helper/MatomoHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public function __construct(ParameterBagInterface $parameterBag)
}

// this file is hosted only on my server
$wrapperFile = sprintf('%s/../../include/wrappers/matomo.php', getcwd());
$wrapperFile = \sprintf('%s/../../include/wrappers/matomo.php', getcwd());

if (file_exists($wrapperFile)) {
/* @noinspection PhpIncludeInspection */
Expand Down
4 changes: 2 additions & 2 deletions src/Controller/RobotsController.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ public function index(): Response
$album = $this->domainHelper->getCurrentAlbum();

/** @var string $robots */
$robots = file_get_contents(sprintf(
$robots = file_get_contents(\sprintf(
'%s/%s',
getcwd(),
$this->packages->getUrl(sprintf(
$this->packages->getUrl(\sprintf(
'assets/robots/%s/robots.txt',
$album->getSlug()
))
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/SitemapController.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public function index(): Response
}

/* @noinspection PhpUnhandledExceptionInspection */
return $this->render(sprintf('album/%s/sitemap.html.twig', $album->getSlug()), [
return $this->render(\sprintf('album/%s/sitemap.html.twig', $album->getSlug()), [
'history' => $history,
'album' => $album,
]);
Expand Down
12 changes: 6 additions & 6 deletions src/DataFixtures/ImageFixtures.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,22 +66,22 @@ public function load(ObjectManager $manager): void
$slug = $album->getSlug();

/** @var Item $itemReference */
$itemReference = $this->getReference(sprintf(ItemFixtures::ITEM_REFERENCE, $slug, $item));
$fileId = sha1(sprintf('%s-%d-%d', $slug, $item, $i));
$itemReference = $this->getReference(\sprintf(ItemFixtures::ITEM_REFERENCE, $slug, $item));
$fileId = sha1(\sprintf('%s-%d-%d', $slug, $item, $i));

$file = (new Image())
->setItem($itemReference)
->setExtension(self::DEFAULT_EXTENSION)
->setDescription(sprintf(self::DEFAULT_DESCRIPTION, $slug, $item, $i))
->setName(sprintf(self::DEFAULT_NAME, $slug, $item, $i))
->setDescription(\sprintf(self::DEFAULT_DESCRIPTION, $slug, $item, $i))
->setName(\sprintf(self::DEFAULT_NAME, $slug, $item, $i))
->setFilename($fileId)
->setIsMain(2 === $i)
->setPosition($i);

$manager->persist($file);
$manager->flush();

$filename = sprintf(
$filename = \sprintf(
'%s/%s.%s',
$this->storagePathProvider->getRelativeDir(StoragePathProvider::PATH_RAW),
$file->getFilename(),
Expand Down Expand Up @@ -137,7 +137,7 @@ private function removeFiles(string $path): void
if (!$filename->isDir()
&& '.gitkeep' !== $filename->getFileName()
&& '.htaccess' !== $filename->getFileName()) {
unlink(sprintf('%s/%s', $path, $filename->getFileName()));
unlink(\sprintf('%s/%s', $path, $filename->getFileName()));
}
}
}
Expand Down
10 changes: 5 additions & 5 deletions src/DataFixtures/ItemFixtures.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,18 @@ public function load(ObjectManager $manager): void
for ($i = 1; $i <= self::ITEM_LIMIT; ++$i) {
$item = (new Item())
->setAlbum($slug)
->setDate((new DateTime())->modify(sprintf('+%d day', $i)))
->setTitle(sprintf(self::DEFAULT_TITLE, $slug, $i))
->setDescription(sprintf(self::DEFAULT_DESCRIPTION, $slug, $i))
->setSlug(sprintf(self::DEFAULT_SLUG, $slug, $i))
->setDate((new DateTime())->modify(\sprintf('+%d day', $i)))
->setTitle(\sprintf(self::DEFAULT_TITLE, $slug, $i))
->setDescription(\sprintf(self::DEFAULT_DESCRIPTION, $slug, $i))
->setSlug(\sprintf(self::DEFAULT_SLUG, $slug, $i))
->setLatitude(self::DEFAULT_LATITUDE)
->setLongitude(self::DEFAULT_LONGITUDE)
->setIsActive(true);

$manager->persist($item);
$manager->flush();

$this->addReference(sprintf(self::ITEM_REFERENCE, $slug, $i), $item);
$this->addReference(\sprintf(self::ITEM_REFERENCE, $slug, $i), $item);
}
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/Entity/Image.php
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public function upload(): void

$this->file->move(
$this->storagePathProvider->getRelativeDir(StoragePathProvider::PATH_RAW),
sprintf('%s.%s', $this->filename, $this->extension)
\sprintf('%s.%s', $this->filename, $this->extension)
);

$this->file = null;
Expand Down Expand Up @@ -152,7 +152,7 @@ public function setFile(UploadedFile $uploadedFile): self
}

$this->extension = $uploadedFile->getClientOriginalExtension();
$this->filename = sha1(sprintf(
$this->filename = sha1(\sprintf(
'%d-%s-%s',
random_int(1, 1000),
uniqid(),
Expand Down
2 changes: 1 addition & 1 deletion src/Entity/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,6 +221,6 @@ public function getIsActive(): bool

public function getGuid(): string
{
return sprintf('%s_%s', $this->getAlbum() ?? '', md5((string) $this->getId()));
return \sprintf('%s_%s', $this->getAlbum() ?? '', md5((string) $this->getId()));
}
}
2 changes: 1 addition & 1 deletion src/Exception/ArrayKeyNotExistsException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ class ArrayKeyNotExistsException extends Exception
{
public function __construct(string $key, int $code = 0, Throwable $previous = null)
{
parent::__construct(sprintf('Array key `%s` not exists', $key), $code, $previous);
parent::__construct(\sprintf('Array key `%s` not exists', $key), $code, $previous);
}
}
2 changes: 1 addition & 1 deletion src/Exception/DomainNotSupportedException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ class DomainNotSupportedException extends Exception
{
public function __construct(string $domain, int $code = 0, Throwable $previous = null)
{
parent::__construct(sprintf('Domain `%s` is not supported', $domain), $code, $previous);
parent::__construct(\sprintf('Domain `%s` is not supported', $domain), $code, $previous);
}
}
2 changes: 1 addition & 1 deletion src/Exception/FileNotExistsException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ class FileNotExistsException extends Exception
{
public function __construct(string $key, int $code = 0, Throwable $previous = null)
{
parent::__construct(sprintf('File `%s` not exists', $key), $code, $previous);
parent::__construct(\sprintf('File `%s` not exists', $key), $code, $previous);
}
}
2 changes: 1 addition & 1 deletion src/Exception/ObjectNotInitializedException.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ class ObjectNotInitializedException extends Exception
{
public function __construct(string $key, int $code = 0, Throwable $previous = null)
{
parent::__construct(sprintf('Class object `%s` not initialized', $key), $code, $previous);
parent::__construct(\sprintf('Class object `%s` not initialized', $key), $code, $previous);
}
}
2 changes: 1 addition & 1 deletion src/Form/ItemType.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ public function __construct(AlbumProvider $albumProvider, AdminSettingsProvider
$albums = $albumProvider->getAll();

foreach ($albums as $album) {
$this->albums[sprintf('%s (%s)', $album->getTitle(), $album->getSlug())] = $album->getSlug();
$this->albums[\sprintf('%s (%s)', $album->getTitle(), $album->getSlug())] = $album->getSlug();
}

$this->defaultAlbum = $adminSettingsProvider->getAlbum();
Expand Down
4 changes: 2 additions & 2 deletions src/Image/ImageConverter.php
Original file line number Diff line number Diff line change
Expand Up @@ -88,10 +88,10 @@ private function addWatermark(
ImageInterface $image
): ImageInterface {
if (!isset($this->watermark[$this->album->getSlug()])) {
$watermarkFile = sprintf(
$watermarkFile = \sprintf(
'%s/public_html%s',
$this->parameterBag->get('kernel.project_dir'),
$this->packages->getUrl(sprintf(
$this->packages->getUrl(\sprintf(
'assets/images/watermark/%s',
$this->album->getWatermark()->getFile()
))
Expand Down
12 changes: 6 additions & 6 deletions src/Provider/StoragePathProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,26 +31,26 @@ public function __construct(ParameterBagInterface $parameterBag)
public function getPublicDir(int $path): string
{
if (self::PATH_IMAGES === $path) {
return sprintf('/%s', $this->storageImagesPath);
return \sprintf('/%s', $this->storageImagesPath);
}

if (self::PATH_THUMBS === $path) {
return sprintf('/%s', $this->storageThumbsPath);
return \sprintf('/%s', $this->storageThumbsPath);
}

return sprintf('/%s', $this->storageRawPath);
return \sprintf('/%s', $this->storageRawPath);
}

public function getRelativeDir(int $path): string
{
if (self::PATH_IMAGES === $path) {
return sprintf(self::RELATIVE_PATH_PATTERN, __DIR__, $this->storageImagesPath);
return \sprintf(self::RELATIVE_PATH_PATTERN, __DIR__, $this->storageImagesPath);
}

if (self::PATH_THUMBS === $path) {
return sprintf(self::RELATIVE_PATH_PATTERN, __DIR__, $this->storageThumbsPath);
return \sprintf(self::RELATIVE_PATH_PATTERN, __DIR__, $this->storageThumbsPath);
}

return sprintf(self::RELATIVE_PATH_PATTERN, __DIR__, $this->storageRawPath);
return \sprintf(self::RELATIVE_PATH_PATTERN, __DIR__, $this->storageRawPath);
}
}
6 changes: 3 additions & 3 deletions src/Repository/ItemRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function getAllPaginated(
): PaginationInterface {
$query = $this
->createQueryBuilder('i')
->orderBy(sprintf('i.%s', $itemsSort), $itemsSortDirection);
->orderBy(\sprintf('i.%s', $itemsSort), $itemsSortDirection);

if ($activeOnly) {
$query
Expand Down Expand Up @@ -83,7 +83,7 @@ public function getById(int $itemId): Item

if (!\is_object($item)) {
/* @noinspection PhpUnhandledExceptionInspection */
throw new RecordNotFoundException(sprintf('No item found for id [%d]', $itemId));
throw new RecordNotFoundException(\sprintf('No item found for id [%d]', $itemId));
}

return $item;
Expand All @@ -103,7 +103,7 @@ public function getBySlug(string $albumSlug, string $itemSlug): Item

if (!$item) {
/* @noinspection PhpUnhandledExceptionInspection */
throw new RecordNotFoundException(sprintf('No item found for slug [%s:%s]', $albumSlug, $itemSlug));
throw new RecordNotFoundException(\sprintf('No item found for slug [%s:%s]', $albumSlug, $itemSlug));
}

return $item;
Expand Down
2 changes: 1 addition & 1 deletion src/Repository/UserRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function __construct(ManagerRegistry $registry)
public function upgradePassword(UserInterface $user, string $newHashedPassword): void
{
if (!$user instanceof User) {
throw new UnsupportedUserException(sprintf('Instances of "%s" are not supported.', $user::class));
throw new UnsupportedUserException(\sprintf('Instances of "%s" are not supported.', $user::class));
}

$user->setPassword($newHashedPassword);
Expand Down
6 changes: 3 additions & 3 deletions src/Twig/RouteExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public function getRouteWithPagination(?string $itemSlug): string
$route = $this->generateRoute($itemSlug);

if (isset($this->attributes['page']) && (int) $this->attributes['page'] > 1) {
return sprintf('%s/%d', $route, $this->attributes['page']);
return \sprintf('%s/%d', $route, $this->attributes['page']);
}

return $route;
Expand All @@ -58,11 +58,11 @@ private function generateRoute(?string $itemSlug): string
$itemSlug = $this->attributes['itemSlug'] ?? null;
}

return sprintf(
return \sprintf(
'http%s://%s%s',
!isset($_SERVER['HTTPS']) || 'on' !== $_SERVER['HTTPS'] ? '' : 's',
$_SERVER['SERVER_NAME'],
empty($itemSlug) ? '' : sprintf('/%s', $itemSlug)
empty($itemSlug) ? '' : \sprintf('/%s', $itemSlug)
);
}
}
2 changes: 1 addition & 1 deletion src/Value/FilePath.php
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,6 @@ public function getRawRelativePath(): string

private function createPath(string $path, string $extension = 'jpg'): string
{
return sprintf('%s/%s.%s', $path, $this->filename, $extension);
return \sprintf('%s/%s.%s', $path, $this->filename, $extension);
}
}
2 changes: 1 addition & 1 deletion tests/Functional/Controller/AlbumControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function testIndex(): void
{
$client = static::createClient();

$client->request('GET', sprintf('https://%s', self::HOST));
$client->request('GET', \sprintf('https://%s', self::HOST));

$this->assertSame(200, $client->getResponse()->getStatusCode());
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Functional/Controller/FeedControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function testIndex(): void
{
$client = static::createClient();

$client->request('GET', sprintf('https://%s/feed', self::HOST));
$client->request('GET', \sprintf('https://%s/feed', self::HOST));

$this->assertSame(200, $client->getResponse()->getStatusCode());
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Functional/Controller/RobotsControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function testIndex(): void
{
$client = static::createClient();

$client->request('GET', sprintf('https://%s/sitemap', self::HOST));
$client->request('GET', \sprintf('https://%s/sitemap', self::HOST));

$this->assertSame(200, $client->getResponse()->getStatusCode());
}
Expand Down
2 changes: 1 addition & 1 deletion tests/Functional/Controller/SecurityControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function testList(): void
{
$client = static::createClient();

$client->request('GET', sprintf('https://%s/zaplecze/login', self::HOST));
$client->request('GET', \sprintf('https://%s/zaplecze/login', self::HOST));

$this->assertSame(200, $client->getResponse()->getStatusCode());
}
Expand Down
4 changes: 2 additions & 2 deletions tests/Functional/Controller/SitemapControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public function testIndex(): void
{
$client = static::createClient();

$client->request('GET', sprintf('https://%s/sitemap', self::HOST));
$client->request('GET', \sprintf('https://%s/sitemap', self::HOST));

$this->assertSame(200, $client->getResponse()->getStatusCode());
}
Expand All @@ -26,7 +26,7 @@ public function testIndexXml(): void
{
$client = static::createClient();

$client->request('GET', sprintf('https://%s/sitemap.xml', self::HOST));
$client->request('GET', \sprintf('https://%s/sitemap.xml', self::HOST));

$this->assertSame(200, $client->getResponse()->getStatusCode());
}
Expand Down

0 comments on commit 9ce840c

Please sign in to comment.