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

eliashaeussler / composer-update-check / 11477119563

23 Oct 2024 09:31AM UTC coverage: 20.394%. Remained the same
11477119563

Pull #149

github

web-flow
Merge 8c76cc2cb into d6e9fe399
Pull Request #149: [TASK] Add schema URLs to all teams components

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
     */
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,
60
    ) {}
×
61

62
    /**
63
     * @param list<self> $items
64
     *
65
     * @see https://github.com/microsoft/AdaptiveCards/blob/main/schemas/src/elements/Container.json
66
     */
67
    public static function container(
×
68
        array $items,
69
        bool $isVisible = true,
70
        string $id = null,
71
        Entity\Report\Enum\TeamsSpacing $spacing = null,
72
    ): self {
73
        return new self(
×
74
            type: 'Container',
×
75
            id: $id,
×
76
            isVisible: $isVisible,
×
77
            items: $items,
×
78
            spacing: $spacing,
×
79
        );
×
80
    }
81

82
    /**
83
     * @param list<TeamsFact> $facts
84
     *
85
     * @see https://github.com/microsoft/AdaptiveCards/blob/main/schemas/src/elements/FactSet.json
86
     */
87
    public static function factSet(array $facts, Entity\Report\Enum\TeamsSpacing $spacing = null): self
×
88
    {
89
        return new self(
×
90
            type: 'FactSet',
×
91
            facts: $facts,
×
92
            spacing: $spacing,
×
93
        );
×
94
    }
95

96
    /**
97
     * @param list<TeamsTableColumn> $columns
98
     * @param list<TeamsTableRow>    $rows
99
     *
100
     * @see https://github.com/microsoft/AdaptiveCards/blob/main/schemas/src/elements/Table.json
101
     */
102
    public static function table(
×
103
        array $columns,
104
        array $rows,
105
        bool $firstRowAsHeader = false,
106
        string $gridStyle = null,
107
    ): self {
108
        return new self(
×
109
            type: 'Table',
×
110
            columns: $columns,
×
111
            firstRowAsHeader: $firstRowAsHeader,
×
112
            gridStyle: $gridStyle,
×
113
            rows: $rows,
×
114
        );
×
115
    }
116

117
    /**
118
     * @see https://github.com/microsoft/AdaptiveCards/blob/main/schemas/src/elements/TextBlock.json
119
     */
120
    public static function textBlock(
×
121
        string $text,
122
        bool $wrap = false,
123
        Entity\Report\Enum\TeamsFontSize $size = null,
124
        Entity\Report\Enum\TeamsSpacing $spacing = null,
125
        Entity\Report\Enum\TeamsFontWeight $weight = null,
126
    ): self {
127
        return new self(
×
128
            type: 'TextBlock',
×
129
            size: $size,
×
130
            spacing: $spacing,
×
131
            text: $text,
×
132
            weight: $weight,
×
133
            wrap: $wrap,
×
134
        );
×
135
    }
136

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

174
        return array_filter($body, static fn (mixed $value) => null !== $value);
×
175
    }
176
}
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