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

eliashaeussler / composer-update-check / 11476967159

23 Oct 2024 09:22AM UTC coverage: 20.394%. First build
11476967159

Pull #130

github

web-flow
Merge pull request #147 from eliashaeussler/task/2.x/teams-enums
Pull Request #130: [!!!][FEATURE] Modernize plugin

347 of 1803 new or added lines in 56 files covered. (19.25%)

373 of 1829 relevant lines covered (20.39%)

1.09 hits per line

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

0.0
/src/Entity/Report/Dto/TeamsContent.php
1
<?php
2

3
declare(strict_types=1);
4

5
/*
6
 * This file is part of the Composer package "eliashaeussler/composer-update-check".
7
 *
8
 * Copyright (C) 2020-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\ComposerUpdateCheck\Entity\Report\Dto;
25

26
use EliasHaeussler\ComposerUpdateCheck\Entity;
27
use JsonSerializable;
28

29
use function array_filter;
30

31
/**
32
 * TeamsContent.
33
 *
34
 * @author Elias Häußler <elias@haeussler.dev>
35
 * @license GPL-3.0-or-later
36
 */
37
final class TeamsContent implements JsonSerializable
38
{
39
    /**
40
     * @param list<TeamsTableColumn>|null $columns
41
     * @param list<TeamsFact>|null        $facts
42
     * @param list<self>|null             $items
43
     * @param list<TeamsTableRow>|null    $rows
44
     */
NEW
45
    private function __construct(
×
46
        public readonly string $type,
47
        public readonly ?array $columns = null,
48
        public readonly ?array $facts = null,
49
        public readonly ?bool $firstRowAsHeader = null,
50
        public readonly ?string $gridStyle = null,
51
        public readonly ?string $id = null,
52
        public readonly ?bool $isVisible = null,
53
        public readonly ?array $items = null,
54
        public readonly ?array $rows = null,
55
        public readonly ?Entity\Report\Enum\TeamsFontSize $size = null,
56
        public readonly ?Entity\Report\Enum\TeamsSpacing $spacing = null,
57
        public readonly ?string $text = null,
58
        public readonly ?Entity\Report\Enum\TeamsFontWeight $weight = null,
59
        public readonly ?bool $wrap = null,
NEW
60
    ) {}
×
61

62
    /**
63
     * @param list<self> $items
64
     */
NEW
65
    public static function container(
×
66
        array $items,
67
        bool $isVisible = true,
68
        string $id = null,
69
        Entity\Report\Enum\TeamsSpacing $spacing = null,
70
    ): self {
NEW
71
        return new self(
×
NEW
72
            type: 'Container',
×
NEW
73
            id: $id,
×
NEW
74
            isVisible: $isVisible,
×
NEW
75
            items: $items,
×
NEW
76
            spacing: $spacing,
×
NEW
77
        );
×
78
    }
79

80
    /**
81
     * @param list<TeamsFact> $facts
82
     */
NEW
83
    public static function factSet(array $facts, Entity\Report\Enum\TeamsSpacing $spacing = null): self
×
84
    {
NEW
85
        return new self(
×
NEW
86
            type: 'FactSet',
×
NEW
87
            facts: $facts,
×
NEW
88
            spacing: $spacing,
×
NEW
89
        );
×
90
    }
91

92
    /**
93
     * @param list<TeamsTableColumn> $columns
94
     * @param list<TeamsTableRow>    $rows
95
     */
NEW
96
    public static function table(
×
97
        array $columns,
98
        array $rows,
99
        bool $firstRowAsHeader = false,
100
        string $gridStyle = null,
101
    ): self {
NEW
102
        return new self(
×
NEW
103
            type: 'Table',
×
NEW
104
            columns: $columns,
×
NEW
105
            firstRowAsHeader: $firstRowAsHeader,
×
NEW
106
            gridStyle: $gridStyle,
×
NEW
107
            rows: $rows,
×
NEW
108
        );
×
109
    }
110

NEW
111
    public static function textBlock(
×
112
        string $text,
113
        bool $wrap = false,
114
        Entity\Report\Enum\TeamsFontSize $size = null,
115
        Entity\Report\Enum\TeamsSpacing $spacing = null,
116
        Entity\Report\Enum\TeamsFontWeight $weight = null,
117
    ): self {
NEW
118
        return new self(
×
NEW
119
            type: 'TextBlock',
×
NEW
120
            size: $size,
×
NEW
121
            spacing: $spacing,
×
NEW
122
            text: $text,
×
NEW
123
            weight: $weight,
×
NEW
124
            wrap: $wrap,
×
NEW
125
        );
×
126
    }
127

128
    /**
129
     * @return array{
130
     *     type: string,
131
     *     columns?: list<TeamsTableColumn>,
132
     *     facts?: list<TeamsFact>,
133
     *     firstRowAsHeader?: bool,
134
     *     gridStyle?: string,
135
     *     id?: string,
136
     *     isVisible?: bool,
137
     *     items?: list<self>,
138
     *     rows?: list<TeamsTableRow>,
139
     *     size?: string,
140
     *     spacing?: string,
141
     *     text?: string,
142
     *     weight?: string,
143
     *     wrap?: bool,
144
     * }
145
     */
NEW
146
    public function jsonSerialize(): array
×
147
    {
NEW
148
        $body = [
×
NEW
149
            'type' => $this->type,
×
NEW
150
            'columns' => $this->columns,
×
NEW
151
            'facts' => $this->facts,
×
NEW
152
            'firstRowAsHeader' => $this->firstRowAsHeader,
×
NEW
153
            'gridStyle' => $this->gridStyle,
×
NEW
154
            'id' => $this->id,
×
NEW
155
            'isVisible' => $this->isVisible,
×
NEW
156
            'items' => $this->items,
×
NEW
157
            'rows' => $this->rows,
×
NEW
158
            'size' => $this->size?->value,
×
NEW
159
            'spacing' => $this->spacing?->value,
×
NEW
160
            'text' => $this->text,
×
NEW
161
            'weight' => $this->weight?->value,
×
NEW
162
            'wrap' => $this->wrap,
×
NEW
163
        ];
×
164

NEW
165
        return array_filter($body, static fn (mixed $value) => null !== $value);
×
166
    }
167
}
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