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

eliashaeussler / version-bumper / 12733193821

12 Jan 2025 11:46AM UTC coverage: 89.51% (-0.2%) from 89.696%
12733193821

Pull #18

github

web-flow
Merge 07ff90b47 into e014d51b3
Pull Request #18: [FEATURE] Allow absence of files to modify via config

3 of 5 new or added lines in 2 files covered. (60.0%)

768 of 858 relevant lines covered (89.51%)

3.9 hits per line

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

70.0
/src/Config/FileToModify.php
1
<?php
2

3
declare(strict_types=1);
4

5
/*
6
 * This file is part of the Composer package "eliashaeussler/version-bumper".
7
 *
8
 * Copyright (C) 2024-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\VersionBumper\Config;
25

26
use EliasHaeussler\VersionBumper\Exception;
27
use Symfony\Component\Filesystem;
28

29
use function is_string;
30

31
/**
32
 * FileToModify.
33
 *
34
 * @author Elias Häußler <elias@haeussler.dev>
35
 * @license GPL-3.0-or-later
36
 */
37
final class FileToModify
38
{
39
    /**
40
     * @var list<FilePattern>
41
     */
42
    private array $patterns = [];
43

44
    /**
45
     * @param list<string|FilePattern> $patterns
46
     *
47
     * @throws Exception\FilePatternIsInvalid
48
     */
49
    public function __construct(
5✔
50
        private readonly string $path,
51
        array $patterns = [],
52
        private readonly bool $reportUnmatched = false,
53
        private readonly bool $reportMissing = true,
54
    ) {
55
        foreach ($patterns as $pattern) {
5✔
56
            $this->add($pattern);
1✔
57
        }
58
    }
59

60
    public function path(): string
×
61
    {
62
        return $this->path;
×
63
    }
64

65
    public function fullPath(string $rootPath): string
2✔
66
    {
67
        if (Filesystem\Path::isAbsolute($this->path)) {
2✔
68
            return $this->path;
1✔
69
        }
70

71
        return Filesystem\Path::join($rootPath, $this->path);
1✔
72
    }
73

74
    /**
75
     * @return list<FilePattern>
76
     */
77
    public function patterns(): array
3✔
78
    {
79
        return $this->patterns;
3✔
80
    }
81

82
    /**
83
     * @throws Exception\FilePatternIsInvalid
84
     */
85
    public function add(string|FilePattern $pattern): self
3✔
86
    {
87
        if (is_string($pattern)) {
3✔
88
            $pattern = new FilePattern($pattern);
2✔
89
        }
90

91
        $this->patterns[] = $pattern;
3✔
92

93
        return $this;
3✔
94
    }
95

96
    public function reportUnmatched(): bool
×
97
    {
98
        return $this->reportUnmatched;
×
99
    }
100

NEW
101
    public function reportMissing(): bool
×
102
    {
NEW
103
        return $this->reportMissing;
×
104
    }
105
}
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