• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

IGNF / validator-api / 24443938672

15 Apr 2026 08:17AM UTC coverage: 51.256% (-2.4%) from 53.632%
24443938672

push

github

web-flow
pdf generator (#85)

* pdf generator

* feat: pdf rapport

* feat: client for pdf rapport

0 of 30 new or added lines in 2 files covered. (0.0%)

347 of 677 relevant lines covered (51.26%)

2.61 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Export/PdfReportWriter.php
1
<?php
2

3
namespace App\Export;
4

5
use App\Entity\Validation;
6
use Knp\Snappy\Pdf;
7
use Twig\Environment;
8

9
class PdfReportWriter
10
{
11
    public function __construct(
12
        private readonly Pdf         $snappy,
13
        private readonly Environment $twig,
NEW
14
    ) {}
×
15

16
    /**
17
     * @param  Validation $validation
18
     * @return string  Raw PDF binary content
19
     */
20
    public function generate(Validation $validation): string
21
    {
NEW
22
        $entries = json_decode($validation->getResults());
×
23

NEW
24
        $hasErrors = (bool) array_filter(
×
NEW
25
            $entries,
×
NEW
26
            static fn(array $e): bool => strtolower($e['level']) === 'error'
×
NEW
27
        );
×
28

NEW
29
        $order  = ['error', 'warning', 'info'];
×
NEW
30
        $grouped = [];
×
31

NEW
32
        foreach ($entries as $entry) {
×
NEW
33
            $grouped[$entry['level']][] = $entry;
×
34
        }
35

NEW
36
        $html = $this->twig->render('pdfModel.html.twig', [
×
NEW
37
            'groupedEntries' => $grouped,
×
NEW
38
            'hasErrors'      => $hasErrors,
×
NEW
39
        ]);
×
40

NEW
41
        return $this->snappy->getOutputFromHtml($html, [
×
NEW
42
            'encoding'             => 'UTF-8',
×
NEW
43
            'enable-local-file-access' => true,
×
NEW
44
            'margin-top'           => '10mm',
×
NEW
45
            'margin-bottom'        => '10mm',
×
NEW
46
            'margin-left'          => '12mm',
×
NEW
47
            'margin-right'         => '12mm',
×
NEW
48
        ]);
×
49
    }
50
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc