Skip to content

Commit d64f4a1

Browse files
committed
Code style fixes
1 parent 053d0ac commit d64f4a1

3 files changed

Lines changed: 16 additions & 24 deletions

File tree

src/Controller/ApiController.php

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
use Symfony\Component\HttpFoundation\JsonResponse;
1818
use Symfony\Component\HttpFoundation\Request;
1919
use Symfony\Component\HttpFoundation\Response;
20-
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
2120
use Symfony\Component\Messenger\Envelope;
2221
use Symfony\Component\Messenger\MessageBusInterface;
2322
use Symfony\Component\Messenger\Stamp\TransportNamesStamp;
@@ -79,13 +78,13 @@ public function packageMetadata(string $packageName): Response
7978
$basePackageName = u($packageName)->trimSuffix('~dev')->toString();
8079

8180
if (null === $package = $this->findPackage($basePackageName)) {
82-
throw new NotFoundHttpException();
81+
throw $this->createNotFoundException();
8382
}
8483

8584
$this->messenger->dispatch(new UpdatePackage($package->getId()));
8685

8786
if (!$this->providerManager->exists($packageName)) {
88-
throw new NotFoundHttpException();
87+
throw $this->createNotFoundException();
8988
}
9089

9190
return new BinaryFileResponse($this->providerManager->path($packageName), headers: ['Content-Type' => 'application/json']);
@@ -105,26 +104,26 @@ public function packageMetadata(string $packageName): Response
105104
public function packageDistribution(string $packageName, string $packageVersion, string $reference, string $type): Response
106105
{
107106
if (!$this->getParameter('dirigent.dist_mirroring.enabled')) {
108-
throw new NotFoundHttpException();
107+
throw $this->createNotFoundException();
109108
}
110109

111110
if (!$this->distributionResolver->exists($packageName, $packageVersion, $reference, $type)) {
112111
if (null === $package = $this->packageRepository->findOneBy(['name' => $packageName])) {
113-
throw new NotFoundHttpException();
112+
throw $this->createNotFoundException();
114113
}
115114

116115
if (null === $version = $this->versionRepository->findOneBy(['package' => $package, 'normalizedVersion' => $packageVersion])) {
117-
throw new NotFoundHttpException();
116+
throw $this->createNotFoundException();
118117
}
119118

120119
if ($version->isDevelopment() && !$this->getParameter('dirigent.dist_mirroring.dev_packages')) {
121-
throw new NotFoundHttpException();
120+
throw $this->createNotFoundException();
122121
}
123122

124123
$this->messenger->dispatch(new UpdatePackage($package->getId()));
125124

126125
if (!$this->distributionResolver->resolve($version, $reference, $type)) {
127-
throw new NotFoundHttpException();
126+
throw $this->createNotFoundException();
128127
}
129128
}
130129

src/Doctrine/Entity/Package.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class Package
5959
#[ORM\Column(nullable: true)]
6060
private ?string $remoteId = null;
6161

62-
#[ORM\Column(type: Types::STRING, enumType: PackageFetchStrategy::class, nullable: true)]
62+
#[ORM\Column(type: Types::STRING, nullable: true, enumType: PackageFetchStrategy::class)]
6363
private PackageFetchStrategy|string|null $fetchStrategy = null;
6464

6565
#[ORM\ManyToOne]

src/EasyAdmin/PackagePaginator.php

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,12 @@
1010

1111
class PackagePaginator implements EntityPaginatorInterface
1212
{
13-
private ?int $currentPage = null;
14-
private ?int $pageSize = null;
15-
private ?int $rangeSize = null;
16-
private ?int $rangeEdgeSize = null;
17-
private $results;
18-
private $numResults;
19-
private ?int $rangeFirstResultNumber = null;
20-
private ?int $rangeLastResultNumber = null;
13+
private int $currentPage;
14+
private int $pageSize;
15+
private int $rangeSize;
16+
private int $rangeEdgeSize;
17+
private array $results;
18+
private int $numResults;
2119

2220
public function __construct(
2321
private readonly UrlGeneratorInterface $router,
@@ -33,18 +31,16 @@ public function paginate(PaginatorDto $paginatorDto, QueryBuilder $queryBuilder)
3331
$this->rangeEdgeSize = $paginatorDto->getRangeEdgeSize();
3432
$this->currentPage = max(1, $paginatorDto->getPageNumber());
3533
$firstResult = ($this->currentPage - 1) * $this->pageSize;
36-
$this->rangeFirstResultNumber = $this->pageSize * ($this->currentPage - 1) + 1;
37-
$this->rangeLastResultNumber = $this->rangeFirstResultNumber + $this->pageSize - 1;
34+
$rangeFirstResultNumber = $this->pageSize * ($this->currentPage - 1) + 1;
3835

3936
$countQueryBuilder = clone $queryBuilder;
4037
$this->numResults = $countQueryBuilder
4138
->select('COUNT(package.id)')
4239
->getQuery()
4340
->getSingleScalarResult();
4441

45-
if ($this->rangeFirstResultNumber > $this->numResults) {
42+
if ($rangeFirstResultNumber > $this->numResults) {
4643
$this->results = [];
47-
$this->rangeLastResultNumber = $this->numResults;
4844

4945
return $this;
5046
}
@@ -57,9 +53,6 @@ public function paginate(PaginatorDto $paginatorDto, QueryBuilder $queryBuilder)
5753
->getResult();
5854

5955
$this->results = $results;
60-
if ($this->rangeLastResultNumber > $this->numResults) {
61-
$this->rangeLastResultNumber = $this->numResults;
62-
}
6356

6457
return $this;
6558
}

0 commit comments

Comments
 (0)