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

eliashaeussler / version-bumper / 24529462145

16 Apr 2026 07:22PM UTC coverage: 88.084% (+0.09%) from 87.996%
24529462145

push

github

web-flow
Merge pull request #125 from eliashaeussler/feature/actions

[FEATURE] Introduce actions

242 of 289 new or added lines in 20 files covered. (83.74%)

2 existing lines in 2 files now uncovered.

1094 of 1242 relevant lines covered (88.08%)

4.98 hits per line

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

65.52
/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(
8✔
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) {
8✔
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
3✔
71
    {
72
        if (Filesystem\Path::isAbsolute($this->path)) {
3✔
73
            return $this->path;
1✔
74
        }
75

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

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

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

98
        $this->patterns[] = $pattern;
3✔
99

100
        return $this;
3✔
101
    }
102

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

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

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

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

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

140
    public function equals(self $other, string $rootPath): bool
1✔
141
    {
142
        return $this->fullPath($rootPath) === $other->fullPath($rootPath);
1✔
143
    }
144
}
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