• 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

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
    ): Result\ActionExecutionResult {
NEW
59
        $exitCode = Console\Command\Command::SUCCESS;
×
NEW
60
        $collectedOutput = new Console\Output\BufferedOutput();
×
NEW
61
        $results = [];
×
62

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

NEW
66
            if ($actionExecutionResult->failed()) {
×
NEW
67
                $exitCode = $actionExecutionResult->exitCode();
×
68
            }
69

NEW
70
            if ($actionExecutionResult->hasOutput()) {
×
NEW
71
                $collectedOutput->writeln($actionExecutionResult->output());
×
72
            }
73

NEW
74
            foreach ($actionExecutionResult->results() as $actionResult) {
×
NEW
75
                $results[] = $actionResult;
×
76
            }
77
        }
78

NEW
79
        $outputString = $collectedOutput->fetch();
×
80

NEW
81
        if ('' === $outputString) {
×
NEW
82
            $outputString = null;
×
83
        }
84

NEW
85
        return new Result\ActionExecutionResult($this, $exitCode, $results, $outputString);
×
86
    }
87

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

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

NEW
100
        return $this;
×
101
    }
102

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

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

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