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

eliashaeussler / version-bumper / 11011333131

24 Sep 2024 09:50AM UTC coverage: 88.978% (+0.3%) from 88.685%
11011333131

push

github

web-flow
Merge pull request #4 from eliashaeussler/feature/report-unmatched

54 of 63 new or added lines in 9 files covered. (85.71%)

2 existing lines in 2 files now uncovered.

331 of 372 relevant lines covered (88.98%)

2.75 hits per line

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

77.78
/src/Result/VersionBumpResult.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 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

29
use function array_values;
30
use function sprintf;
31

32
/**
33
 * VersionBumpResult.
34
 *
35
 * @author Elias Häußler <elias@haeussler.dev>
36
 * @license GPL-3.0-or-later
37
 */
38
final class VersionBumpResult
39
{
40
    /**
41
     * @param list<WriteOperation> $operations
42
     */
43
    public function __construct(
2✔
44
        private readonly Config\FileToModify $file,
45
        private readonly array $operations,
46
    ) {}
2✔
47

48
    public function file(): Config\FileToModify
×
49
    {
50
        return $this->file;
×
51
    }
52

53
    /**
54
     * @return list<WriteOperation>
55
     */
56
    public function operations(): array
×
57
    {
58
        return $this->operations;
×
59
    }
60

NEW
61
    public function hasOperations(): bool
×
62
    {
NEW
63
        return [] !== $this->operations;
×
64
    }
65

66
    /**
67
     * @return list<non-empty-list<WriteOperation>>
68
     */
69
    public function groupedOperations(): array
1✔
70
    {
71
        $operations = [];
1✔
72

73
        foreach ($this->operations as $operation) {
1✔
74
            $identifier = sprintf(
1✔
75
                '%s_%s_%s_%s',
1✔
76
                $operation->source()?->full(),
1✔
77
                $operation->target()?->full(),
1✔
78
                $operation->state()->name,
1✔
79
                Enum\OperationState::Unmatched === $operation->state() ? $operation->pattern()->original() : '',
1✔
80
            );
1✔
81

82
            if (!isset($operations[$identifier])) {
1✔
83
                $operations[$identifier] = [];
1✔
84
            }
85

86
            $operations[$identifier][] = $operation;
1✔
87
        }
88

89
        return array_values($operations);
1✔
90
    }
91

92
    public function hasUnmatchedReports(): bool
1✔
93
    {
94
        foreach ($this->operations as $operation) {
1✔
95
            if (Enum\OperationState::Unmatched === $operation->state()) {
1✔
96
                return true;
1✔
97
            }
98
        }
99

100
        return false;
1✔
101
    }
102
}
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

© 2025 Coveralls, Inc