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

eliashaeussler / version-bumper / 24362660792

13 Apr 2026 07:28PM UTC coverage: 76.132% (-11.9%) from 87.996%
24362660792

Pull #125

github

eliashaeussler
[FEATURE] Introduce actions
Pull Request #125: [FEATURE] Introduce actions

73 of 260 new or added lines in 20 files covered. (28.08%)

3 existing lines in 3 files now uncovered.

925 of 1215 relevant lines covered (76.13%)

4.14 hits per line

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

48.28
/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-2026 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 EliasHaeussler\VersionBumper\Version;
28
use Symfony\Component\Filesystem;
29

30
use function is_string;
31

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

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

65
    public function path(): string
×
66
    {
67
        return $this->path;
×
68
    }
69

70
    public function fullPath(string $rootPath): string
2✔
71
    {
72
        if (Filesystem\Path::isAbsolute($this->path)) {
2✔
73
            return $this->path;
1✔
74
        }
75

76
        return Filesystem\Path::join($rootPath, $this->path);
1✔
77
    }
78

79
    /**
80
     * @return list<FilePattern>
81
     */
82
    public function patterns(): array
3✔
83
    {
84
        return $this->patterns;
3✔
85
    }
86

87
    /**
88
     * @throws Exception\FilePatternIsInvalid
89
     */
90
    public function add(string|FilePattern $pattern): self
3✔
91
    {
92
        if (is_string($pattern)) {
3✔
93
            $pattern = new FilePattern($pattern);
2✔
94
        }
95

96
        $this->patterns[] = $pattern;
3✔
97

98
        return $this;
3✔
99
    }
100

101
    public function reportUnmatched(): bool
×
102
    {
103
        return $this->reportUnmatched;
×
104
    }
105

106
    public function reportMissing(): bool
×
107
    {
108
        return $this->reportMissing;
×
109
    }
110

111
    /**
112
     * @return list<Version\Action\Action>
113
     */
NEW
114
    public function preActions(): array
×
115
    {
NEW
116
        return $this->preActions;
×
117
    }
118

119
    /**
120
     * @return list<Version\Action\Action>
121
     */
NEW
122
    public function postActions(): array
×
123
    {
NEW
124
        return $this->postActions;
×
125
    }
126

127
    /**
128
     * @return list<Version\Action\Action>
129
     */
NEW
130
    public function getActionsByType(Version\Action\ActionType $type): array
×
131
    {
132
        return match ($type) {
NEW
133
            Version\Action\ActionType::PreAction => $this->preActions,
×
NEW
134
            Version\Action\ActionType::PostAction => $this->postActions,
×
135
        };
136
    }
137

NEW
138
    public function equals(self $other, string $rootPath): bool
×
139
    {
NEW
140
        return $this->fullPath($rootPath) === $other->fullPath($rootPath);
×
141
    }
142
}
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