Lines 100.00% 1 / 1
Functions and Methods 100.00% 1 / 1
Classes and Traits 100.00% 1 / 1
Name Lines Functions and Methods CRAP Classes and Traits
LinkList 100.00% 1 / 1 100.00% 1 / 1 1 100.00% 1 / 1
 __construct 100.00% 1 / 1 100.00% 1 / 1 1
1<?php
2
3declare(strict_types=1);
4
5namespace App\ApiResource;
6
7use ApiPlatform\Metadata\ApiProperty;
8use ApiPlatform\Metadata\ApiResource;
9use ApiPlatform\Metadata\Get;
10use App\LinkList\LinkSection;
11use App\State\LinkListProvider;
12use Symfony\Component\Serializer\Attribute\Groups;
13
14/**
15 * GET /api/links: the Ingress link list of docs/links.md (LinkListParser), for everyone. The
16 * website's /links page shows the same.
17 */
18#[ApiResource(
19    description: 'The Ingress link list, from docs/links.md in the repository (changed with pull requests, live after the next deploy): sections with a title and links (title, url, description or null). Public, no sign-in needed.',
20    operations: [
21        new Get(
22            uriTemplate: '/links',
23            cacheHeaders: ['max_age' => 3600, 'public' => true],
24            provider: LinkListProvider::class,
25        ),
26    ],
27    normalizationContext: ['groups' => [self::READ]],
28)]
29final readonly class LinkList
30{
31    public const string READ = 'link-list:read';
32
33    /**
34     * @param list<LinkSection> $sections
35     * @param list<string>      $problems entries not in the list's format, with their line; not in the API
36     */
37    public function __construct(
38        #[Groups([self::READ])]
39        #[ApiProperty(genId: false)]
40        public array $sections = [],
41        public array $problems = [],
42    ) {
43    }
44}