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

eliashaeussler / version-bumper / 24363916924

13 Apr 2026 07:58PM UTC coverage: 75.792% (-12.2%) from 87.996%
24363916924

Pull #125

github

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

83 of 278 new or added lines in 20 files covered. (29.86%)

2 existing lines in 2 files now uncovered.

933 of 1231 relevant lines covered (75.79%)

4.1 hits per line

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

0.0
/src/Version/Action/ActionCollection.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\Version\Action;
25

26
use ArrayIterator;
27
use Countable;
28
use EliasHaeussler\VersionBumper\Config;
29
use EliasHaeussler\VersionBumper\Result;
30
use IteratorAggregate;
31
use Symfony\Component\Console;
32

33
use function count;
34

35
/**
36
 * ActionCollection.
37
 *
38
 * @author Elias Häußler <elias@haeussler.dev>
39
 * @license GPL-3.0-or-later
40
 *
41
 * @internal
42
 *
43
 * @implements IteratorAggregate<Action>
44
 */
45
final class ActionCollection implements Action, Countable, IteratorAggregate
46
{
47
    /**
48
     * @param list<Action> $actions
49
     */
NEW
50
    public function __construct(
×
51
        private array $actions = [],
NEW
52
    ) {}
×
53

NEW
54
    public function execute(
×
55
        string $rootPath,
56
        Config\FileToModify $sourceFile,
57
        Console\Output\OutputInterface $output,
58
        bool $failOnFirstError = false,
59
    ): Result\ActionExecutionResult {
NEW
60
        $exitCode = Console\Command\Command::SUCCESS;
×
NEW
61
        $collectedOutput = new Console\Output\BufferedOutput();
×
NEW
62
        $results = [];
×
63

NEW
64
        foreach ($this->actions as $action) {
×
NEW
65
            $actionExecutionResult = $action->execute($rootPath, $sourceFile, $output);
×
66

NEW
67
            if ($actionExecutionResult->hasOutput()) {
×
NEW
68
                $collectedOutput->writeln($actionExecutionResult->output());
×
69
            }
70

NEW
71
            foreach ($actionExecutionResult->results() as $actionResult) {
×
NEW
72
                $results[] = $actionResult;
×
73
            }
74

NEW
75
            if (!$actionExecutionResult->failed()) {
×
NEW
76
                continue;
×
77
            }
78

NEW
79
            $exitCode = $actionExecutionResult->exitCode();
×
80

NEW
81
            if ($failOnFirstError) {
×
NEW
82
                break;
×
83
            }
84
        }
85

NEW
86
        return new Result\ActionExecutionResult($this, $exitCode, $results, $collectedOutput->fetch());
×
87
    }
88

89
    /**
90
     * @return list<Action>
91
     */
NEW
92
    public function actions(): array
×
93
    {
NEW
94
        return $this->actions;
×
95
    }
96

NEW
97
    public function add(Action $action): self
×
98
    {
NEW
99
        $this->actions[] = $action;
×
100

NEW
101
        return $this;
×
102
    }
103

NEW
104
    public function count(): int
×
105
    {
NEW
106
        return count($this->actions);
×
107
    }
108

109
    /**
110
     * @return ArrayIterator<int, Action>
111
     */
NEW
112
    public function getIterator(): ArrayIterator
×
113
    {
NEW
114
        return new ArrayIterator($this->actions);
×
115
    }
116

NEW
117
    public static function getIdentifier(): string
×
118
    {
NEW
119
        return 'collection';
×
120
    }
121
}
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