• 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

58.62
/src/Result/WriteOperation.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\Result;
25

26
use EliasHaeussler\VersionBumper\Config;
27
use EliasHaeussler\VersionBumper\Enum;
28
use EliasHaeussler\VersionBumper\Exception;
29
use EliasHaeussler\VersionBumper\Version;
30

31
/**
32
 * WriteOperation.
33
 *
34
 * @author Elias Häußler <elias@haeussler.dev>
35
 * @license GPL-3.0-or-later
36
 */
37
final readonly class WriteOperation
38
{
39
    /**
40
     * @throws Exception\FilePatternIsMissing
41
     * @throws Exception\SourceVersionIsMissing
42
     * @throws Exception\TargetVersionIsMissing
43
     * @throws Exception\VersionBumpResultIsMissing
44
     */
45
    public function __construct(
5✔
46
        private ?Version\Version $source,
47
        private ?Version\Version $target,
48
        private ?string $result,
49
        private ?Config\FilePattern $pattern,
50
        private Enum\OperationState $state,
51
    ) {
52
        $this->validate();
5✔
53
    }
54

55
    public static function unmatched(Config\FilePattern $pattern): self
1✔
56
    {
57
        return new self(null, null, null, $pattern, Enum\OperationState::Unmatched);
1✔
58
    }
59

NEW
60
    public static function regenerated(): self
×
61
    {
NEW
62
        return new self(null, null, null, null, Enum\OperationState::Regenerated);
×
63
    }
64

UNCOV
65
    public function source(): ?Version\Version
×
66
    {
67
        return $this->source;
×
68
    }
69

70
    public function target(): ?Version\Version
×
71
    {
72
        return $this->target;
×
73
    }
74

75
    public function result(): ?string
×
76
    {
77
        return $this->result;
×
78
    }
79

NEW
80
    public function pattern(): ?Config\FilePattern
×
81
    {
82
        return $this->pattern;
×
83
    }
84

85
    /**
86
     * @phpstan-assert-if-true !null $this->source()
87
     * @phpstan-assert-if-true !null $this->target()
88
     * @phpstan-assert-if-true !null $this->result()
89
     * @phpstan-assert-if-true !null $this->pattern()
90
     */
91
    public function matched(): bool
1✔
92
    {
93
        return $this->state->matched();
1✔
94
    }
95

96
    public function state(): Enum\OperationState
×
97
    {
98
        return $this->state;
×
99
    }
100

101
    /**
102
     * @throws Exception\FilePatternIsMissing
103
     * @throws Exception\SourceVersionIsMissing
104
     * @throws Exception\TargetVersionIsMissing
105
     * @throws Exception\VersionBumpResultIsMissing
106
     */
107
    private function validate(): void
5✔
108
    {
109
        if (!$this->state->matched()) {
5✔
110
            return;
1✔
111
        }
112

113
        if (null === $this->source) {
5✔
114
            throw new Exception\SourceVersionIsMissing();
1✔
115
        }
116
        if (null === $this->target) {
5✔
117
            throw new Exception\TargetVersionIsMissing();
1✔
118
        }
119
        if (null === $this->result) {
5✔
120
            throw new Exception\VersionBumpResultIsMissing();
1✔
121
        }
122
        if (null === $this->pattern) {
5✔
123
            throw new Exception\FilePatternIsMissing();
1✔
124
        }
125
    }
126
}
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