Skip to content

Commit 711c758

Browse files
committed
Ajout de types natifs
1 parent 4b03f76 commit 711c758

2 files changed

Lines changed: 6 additions & 11 deletions

File tree

sources/AppBundle/Controller/Admin/Planete/FeedArticleListAction.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,17 @@
99
use Symfony\Component\HttpFoundation\Response;
1010
use Twig\Environment;
1111

12-
class FeedArticleListAction
12+
final readonly class FeedArticleListAction
1313
{
1414
public function __construct(
15-
private readonly FeedArticleRepository $feedArticleRepository,
16-
private readonly Environment $twig,
15+
private FeedArticleRepository $feedArticleRepository,
16+
private Environment $twig,
1717
) {}
1818

1919
public function __invoke(Request $request): Response
2020
{
21-
$sort = $request->query->get('sort', 'title');
22-
$direction = $request->query->get('direction', 'asc');
21+
$sort = $request->query->getString('sort', 'title');
22+
$direction = $request->query->getString('direction', 'asc');
2323

2424
return new Response($this->twig->render('admin/planete/feed_article_list.html.twig', [
2525
'articles' => $this->feedArticleRepository->search($sort, $direction, 20),

sources/PlanetePHP/FeedArticleRepository.php

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -36,20 +36,15 @@ public function countRelevant(): int
3636
}
3737

3838
/**
39-
* @param string $sort
40-
* @param string $direction
41-
* @param int $limit
42-
*
4339
* @return FeedArticle[]
4440
*/
45-
public function search($sort, $direction, $limit = 20): array
41+
public function search(string $sort, string $direction, int $limit = 20): array
4642
{
4743
$sorts = [
4844
'title' => 'b.titre',
4945
'content' => 'b.contenu',
5046
'status' => 'b.etat',
5147
];
52-
Assertion::integer($limit);
5348
Assertion::keyExists($sorts, $sort);
5449
Assertion::inArray($direction, ['asc', 'desc']);
5550
$qb = $this->connection->createQueryBuilder();

0 commit comments

Comments
 (0)