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

eliashaeussler / version-bumper / 24533142108

16 Apr 2026 08:46PM UTC coverage: 88.438% (+0.2%) from 88.235%
24533142108

push

github

web-flow
Merge pull request #129 from eliashaeussler/task/readonly

1155 of 1306 relevant lines covered (88.44%)

5.05 hits per line

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

69.23
/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 readonly class ActionCollection implements Action, Countable, IteratorAggregate
46
{
47
    /**
48
     * @param list<Action> $actions
49
     */
50
    public function __construct(
4✔
51
        private array $actions = [],
52
    ) {}
4✔
53

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

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

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

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

75
            if (!$actionExecutionResult->failed()) {
3✔
76
                continue;
2✔
77
            }
78

79
            $exitCode = $actionExecutionResult->exitCode();
2✔
80

81
            if ($failOnFirstError) {
2✔
82
                break;
1✔
83
            }
84
        }
85

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

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

97
    public function count(): int
×
98
    {
99
        return count($this->actions);
×
100
    }
101

102
    /**
103
     * @return ArrayIterator<int, Action>
104
     */
105
    public function getIterator(): ArrayIterator
×
106
    {
107
        return new ArrayIterator($this->actions);
×
108
    }
109

110
    public static function getIdentifier(): string
×
111
    {
112
        return 'collection';
×
113
    }
114
}
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