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

eliashaeussler / composer-package-url-generator / 17540936684

08 Sep 2025 12:46AM UTC coverage: 92.308%. Remained the same
17540936684

push

github

web-flow
[TASK] Update all dependencies

132 of 143 relevant lines covered (92.31%)

3.01 hits per line

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

73.33
/src/Url/Generator/GenericUrlGenerator.php
1
<?php
2

3
declare(strict_types=1);
4

5
/*
6
 * This file is part of the Composer package "eliashaeussler/composer-package-url-generator".
7
 *
8
 * Copyright (C) 2023-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\ComposerPackageUrlGenerator\Url\Generator;
25

26
use Composer\Package;
27
use EliasHaeussler\ComposerPackageUrlGenerator\Exception;
28
use EliasHaeussler\ComposerPackageUrlGenerator\Helper;
29
use Psr\Http\Message;
30

31
/**
32
 * GenericUrlGenerator.
33
 *
34
 * @author Elias Häußler <elias@haeussler.dev>
35
 * @license GPL-3.0-or-later
36
 */
37
final class GenericUrlGenerator implements UrlGenerator
38
{
39
    /**
40
     * @throws Exception\NoSourceUrlAvailable
41
     * @throws Exception\UrlIsMalformed
42
     */
43
    public function generateSourceUrl(Package\PackageInterface $package): Message\UriInterface
2✔
44
    {
45
        $sourceUrls = $package->getSourceUrls();
2✔
46

47
        foreach ($sourceUrls as $sourceUrl) {
2✔
48
            return Helper\UrlHelper::normalizeUrl($sourceUrl);
1✔
49
        }
50

51
        throw new Exception\NoSourceUrlAvailable($package->getName());
1✔
52
    }
53

54
    /**
55
     * @throws Exception\UrlIsMalformed
56
     */
57
    public function generateHomepageUrl(Package\PackageInterface $package): ?Message\UriInterface
3✔
58
    {
59
        if (!($package instanceof Package\CompletePackageInterface)) {
3✔
60
            return null;
1✔
61
        }
62

63
        if (null !== ($homepageUrl = $package->getHomepage())) {
2✔
64
            return Helper\UrlHelper::normalizeUrl($homepageUrl);
1✔
65
        }
66

67
        return null;
1✔
68
    }
69

70
    public function supports(Package\PackageInterface $package): bool
×
71
    {
72
        return true;
×
73
    }
74

75
    public static function getPriority(): int
×
76
    {
77
        return PHP_INT_MIN;
×
78
    }
79
}
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