Failed Conditions
Push — master ( 37c7e1...8f957f )
by Zbigniew
05:34
created

MessageFactory::elementOverflowMenu()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 8
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 4
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
/*
6
 * This file is part of the zibios/sharep.
7
 *
8
 * (c) Zbigniew Ślązak
9
 */
10
11
namespace App\Slack\MessageBuilder;
12
13
use App\Slack\MessageBuilder\Block\ActionsBlock;
14
use App\Slack\MessageBuilder\Block\BlockInterface;
15
use App\Slack\MessageBuilder\Block\ContextBlock;
16
use App\Slack\MessageBuilder\Block\DividerBlock;
17
use App\Slack\MessageBuilder\Block\ImageBlock;
18
use App\Slack\MessageBuilder\Block\InputBlock;
19
use App\Slack\MessageBuilder\Block\SectionBlock;
20
use App\Slack\MessageBuilder\Element\ActionsBlockElementInterface;
21
use App\Slack\MessageBuilder\Element\ButtonElement;
22
use App\Slack\MessageBuilder\Element\ContextBlockElementInterface;
23
use App\Slack\MessageBuilder\Element\DatePickerElement;
24
use App\Slack\MessageBuilder\Element\ImageElement;
25
use App\Slack\MessageBuilder\Element\InputBlockElementInterface;
26
use App\Slack\MessageBuilder\Element\MarkdownTextElement;
27
use App\Slack\MessageBuilder\Element\MultiSelectExternalElement;
28
use App\Slack\MessageBuilder\Element\MultiSelectStaticElement;
29
use App\Slack\MessageBuilder\Element\MultiSelectUserElement;
30
use App\Slack\MessageBuilder\Element\OverflowMenuElement;
31
use App\Slack\MessageBuilder\Element\PlainTextElement;
32
use App\Slack\MessageBuilder\Element\PlainTextInputElement;
33
use App\Slack\MessageBuilder\Element\SectionBlockAccessoryInterface;
34
use App\Slack\MessageBuilder\Element\SelectExternalElement;
35
use App\Slack\MessageBuilder\Element\SelectStaticElement;
36
use App\Slack\MessageBuilder\Element\SelectUserElement;
37
use App\Slack\MessageBuilder\Element\TextElementInterface;
38
use App\Slack\MessageBuilder\Enum\ButtonStyleEnum;
39
use App\Slack\MessageBuilder\Object\ConfirmationDialogObject;
40
use App\Slack\MessageBuilder\Object\OptionObject;
41
42
class MessageFactory
43
{
44 3
    public function layout(BlockInterface ...$blocks): Layout
45
    {
46 3
        return new Layout(...$blocks);
47
    }
48
49
    //------------------------------------------------------------------------------------------------------------------
50
51
    public function blockActions(
52
        ActionsBlockElementInterface ...$elements
53
    ): ActionsBlock {
54
        return new ActionsBlock(...$elements);
55
    }
56
57
    public function blockContext(
58
        ContextBlockElementInterface ...$elements
59
    ): ContextBlock {
60
        return new ContextBlock(...$elements);
61
    }
62
63
    public function blockDivider(): DividerBlock
64
    {
65
        return new DividerBlock();
66
    }
67
68
    public function blockImage(
69
        string $imageUrl,
70
        string $altText,
71
        string $title = ''
72
    ): ImageBlock {
73
        return new ImageBlock($imageUrl, $altText, $title);
74
    }
75
76
    public function blockInput(
77
        string $label,
78
        InputBlockElementInterface $element,
79
        bool $optional = false,
80
        string $hint = ''
81
    ): InputBlock {
82
        return new InputBlock($label, $element, $optional, $hint);
83
    }
84
85 3
    public function blockSection(
86
        TextElementInterface $text,
87
        SectionBlockAccessoryInterface $accessory = null,
88
        TextElementInterface ...$fields
89
    ): SectionBlock {
90 3
        return new SectionBlock($text, $accessory, ...$fields);
91
    }
92
93
    //------------------------------------------------------------------------------------------------------------------
94
95
    public function elementButton(
96
        string $text,
97
        string $actionId,
98
        ButtonStyleEnum $style = null,
99
        ConfirmationDialogObject $confirm = null,
100
        string $value = '',
101
        string $url = ''
102
    ): ButtonElement {
103
        return new ButtonElement($text, $actionId, $style, $confirm, $value, $url);
104
    }
105
106 1
    public function elementDatePicker(
107
        string $actionId,
108
        string $placeholder = '',
109
        string $initialDate = '',
110
        ConfirmationDialogObject $confirmDialog = null
111
    ): DatePickerElement {
112 1
        return new DatePickerElement($actionId, $placeholder, $initialDate, $confirmDialog);
113
    }
114
115
    public function elementImage(
116
        string $imageUrl,
117
        string $altText
118
    ): ImageElement {
119
        return new ImageElement($imageUrl, $altText);
120
    }
121
122
    public function elementMarkdownText(
123
        string $text
124
    ): MarkdownTextElement {
125
        return new MarkdownTextElement($text);
126
    }
127
128
    public function elementMultiSelectExternal(
129
        string $placeholder,
130
        string $actionId,
131
        int $minQueryLength,
132
        OptionObject $initialOption = null,
133
        ConfirmationDialogObject $confirmDialog = null
134
    ): MultiSelectExternalElement {
135
        return new MultiSelectExternalElement($placeholder, $actionId, $minQueryLength, $initialOption, $confirmDialog);
136
    }
137
138 View Code Duplication
    public function elementMultiSelectStatic(
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
139
        string $placeholder,
140
        string $actionId,
141
        OptionObject $initialOption = null,
142
        ConfirmationDialogObject $confirmDialog = null,
143
        OptionObject ...$options
144
    ): MultiSelectStaticElement {
145
        return new MultiSelectStaticElement($placeholder, $actionId, $initialOption, $confirmDialog, $options);
146
    }
147
148
    public function elementMultiSelectUser(
149
        string $placeholder,
150
        string $actionId,
151
        string $initialUser,
152
        ConfirmationDialogObject $confirmDialog = null
153
    ): MultiSelectUserElement {
154
        return new MultiSelectUserElement($placeholder, $actionId, $initialUser, $confirmDialog);
155
    }
156
157
    public function elementOverflowMenu(
158
        string $placeholder,
159
        string $actionId,
160
        ConfirmationDialogObject $confirmDialog = null,
161
        OptionObject ...$options
162
    ): OverflowMenuElement {
163
        return new OverflowMenuElement($placeholder, $actionId, $confirmDialog, $options);
164
    }
165
166 3
    public function elementPlainText(
167
        string $text
168
    ): PlainTextElement {
169 3
        return new PlainTextElement($text);
170
    }
171
172
    public function elementPlainTextInput(
173
        string $actionId,
174
        string $placeholder = '',
175
        string $initialValue = '',
176
        bool $multiline = false,
177
        int $minLength = 1,
178
        int $maxLength = 3000
179
    ): PlainTextInputElement {
180
        return new PlainTextInputElement($actionId, $placeholder, $initialValue, $multiline, $minLength, $maxLength);
181
    }
182
183
    public function elementSelectExternal(
184
        string $placeholder,
185
        string $actionId,
186
        int $minQueryLength,
187
        OptionObject $initialOption = null,
188
        ConfirmationDialogObject $confirmDialog = null
189
    ): SelectExternalElement {
190
        return new SelectExternalElement($placeholder, $actionId, $minQueryLength, $initialOption, $confirmDialog);
191
    }
192
193 View Code Duplication
    public function elementSelectStatic(
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
194
        string $placeholder,
195
        string $actionId,
196
        OptionObject $initialOption = null,
197
        ConfirmationDialogObject $confirmDialog = null,
198
        OptionObject ...$options
199
    ): SelectStaticElement {
200
        return new SelectStaticElement($placeholder, $actionId, $initialOption, $confirmDialog, $options);
201
    }
202
203
    public function elementSelectUserText(
204
        string $placeholder,
205
        string $actionId,
206
        string $initialUser,
207
        ConfirmationDialogObject $confirmDialog = null
208
    ): SelectUserElement {
209
        return new SelectUserElement($placeholder, $actionId, $initialUser, $confirmDialog);
210
    }
211
212
    //------------------------------------------------------------------------------------------------------------------
213
}
214