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

eliashaeussler / composer-update-check / 16900093970

12 Aug 2025 05:43AM UTC coverage: 20.538%. First build
16900093970

Pull #130

github

web-flow
Merge pull request #188 from eliashaeussler/renovate/composer-composer-2.x-lockfile
Pull Request #130: [!!!][FEATURE] Modernize plugin

356 of 1832 new or added lines in 57 files covered. (19.43%)

382 of 1860 relevant lines covered (20.54%)

1.11 hits per line

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

57.5
/src/Entity/Security/SecurityAdvisory.php
1
<?php
2

3
declare(strict_types=1);
4

5
/*
6
 * This file is part of the Composer package "eliashaeussler/composer-update-check".
7
 *
8
 * Copyright (C) 2020-2025 Elias Häußler <elias@haeussler.dev>
9
 *
10
 * This program is free software: you can redistribute it and/or modify
11
 * it under the terms of the GNU General Public License as published by
12
 * the Free Software Foundation, either version 3 of the License, or
13
 * (at your option) any later version.
14
 *
15
 * This program is distributed in the hope that it will be useful,
16
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
 * GNU General Public License for more details.
19
 *
20
 * You should have received a copy of the GNU General Public License
21
 * along with this program. If not, see <https://www.gnu.org/licenses/>.
22
 */
23

24
namespace EliasHaeussler\ComposerUpdateCheck\Entity\Security;
25

26
use DateTimeImmutable;
27
use JsonSerializable;
28
use Psr\Http\Message;
29

30
use function preg_quote;
31
use function preg_replace;
32
use function sprintf;
33

34
/**
35
 * SecurityAdvisory.
36
 *
37
 * @author Elias Häußler <elias@haeussler.dev>
38
 * @license GPL-3.0-or-later
39
 */
40
final class SecurityAdvisory implements JsonSerializable
41
{
42
    public function __construct(
3✔
43
        private readonly string $packageName,
44
        private readonly string $advisoryId,
45
        private readonly string $affectedVersions,
46
        private readonly string $title,
47
        private readonly DateTimeImmutable $reportedAt,
48
        private readonly SeverityLevel $severity,
49
        private readonly ?string $cve = null,
50
        private readonly ?Message\UriInterface $link = null,
51
    ) {}
3✔
52

NEW
53
    public function getPackageName(): string
×
54
    {
NEW
55
        return $this->packageName;
×
56
    }
57

NEW
58
    public function getAdvisoryId(): string
×
59
    {
NEW
60
        return $this->advisoryId;
×
61
    }
62

NEW
63
    public function getAffectedVersions(): string
×
64
    {
NEW
65
        return $this->affectedVersions;
×
66
    }
67

NEW
68
    public function getTitle(): string
×
69
    {
NEW
70
        return $this->title;
×
71
    }
72

73
    public function getSanitizedTitle(): string
2✔
74
    {
75
        if (null === $this->cve) {
2✔
76
            return $this->title;
1✔
77
        }
78

79
        $sanitizedTitle = preg_replace(
1✔
80
            sprintf('/^%s:\s/', preg_quote($this->cve)),
1✔
81
            '',
1✔
82
            $this->title,
1✔
83
        );
1✔
84

85
        if (null === $sanitizedTitle) {
1✔
NEW
86
            return $this->title;
×
87
        }
88

89
        return $sanitizedTitle;
1✔
90
    }
91

NEW
92
    public function getReportedAt(): DateTimeImmutable
×
93
    {
NEW
94
        return $this->reportedAt;
×
95
    }
96

NEW
97
    public function getSeverity(): SeverityLevel
×
98
    {
NEW
99
        return $this->severity;
×
100
    }
101

NEW
102
    public function getCVE(): ?string
×
103
    {
NEW
104
        return $this->cve;
×
105
    }
106

NEW
107
    public function getLink(): ?Message\UriInterface
×
108
    {
NEW
109
        return $this->link;
×
110
    }
111

112
    /**
113
     * @return array{
114
     *     packageName: string,
115
     *     advisoryId: string,
116
     *     affectedVersions: string,
117
     *     title: string,
118
     *     reportedAt: DateTimeImmutable,
119
     *     severity: string,
120
     *     cve: string|null,
121
     *     link: string|null,
122
     * }
123
     */
124
    public function jsonSerialize(): array
1✔
125
    {
126
        return [
1✔
127
            'packageName' => $this->packageName,
1✔
128
            'advisoryId' => $this->advisoryId,
1✔
129
            'affectedVersions' => $this->affectedVersions,
1✔
130
            'title' => $this->title,
1✔
131
            'reportedAt' => $this->reportedAt,
1✔
132
            'severity' => $this->severity->value,
1✔
133
            'cve' => $this->cve,
1✔
134
            'link' => null !== $this->link ? (string) $this->link : null,
1✔
135
        ];
1✔
136
    }
137
}
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

© 2025 Coveralls, Inc