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

contributte / datagrid / 8230471191

11 Mar 2024 09:25AM UTC coverage: 34.102%. First build
8230471191

Pull #1060

github

radimvaculik
Fix phpstan
Pull Request #1060: [7.x] Next

117 of 435 new or added lines in 54 files covered. (26.9%)

1124 of 3296 relevant lines covered (34.1%)

0.34 hits per line

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

26.83
/src/Status/Option.php
1
<?php declare(strict_types = 1);
2

3
namespace Contributte\Datagrid\Status;
4

5
use Contributte\Datagrid\Column\Action\Confirmation\CallbackConfirmation;
6
use Contributte\Datagrid\Column\Action\Confirmation\IConfirmation;
7
use Contributte\Datagrid\Column\Action\Confirmation\StringConfirmation;
8
use Contributte\Datagrid\Column\ColumnStatus;
9
use Contributte\Datagrid\Datagrid;
10
use Contributte\Datagrid\Exception\DatagridException;
11
use Contributte\Datagrid\Row;
12

13
class Option
14
{
15

16
        protected ?string $title = null;
17

18
        protected string $class = 'btn-success';
19

20
        protected string $classSecondary = 'btn btn-xs';
21

22
        protected string $classInDropdown = 'ajax dropdown-item';
23

24
        protected ?string $icon = null;
25

26
        protected ?string $iconSecondary = null;
27

28
        protected ?IConfirmation $confirmation = null;
29

30
        public function __construct(private Datagrid $grid, protected ColumnStatus $columnStatus, protected mixed $value, protected string $text)
1✔
31
        {
32
        }
1✔
33

34
        public function getValue(): mixed
35
        {
36
                return $this->value;
1✔
37
        }
38

39
        public function endOption(): ColumnStatus
40
        {
41
                return $this->columnStatus;
1✔
42
        }
43

44
        /**
45
         * @return static
46
         */
47
        public function setTitle(string $title): self
48
        {
49
                $this->title = $title;
×
50

51
                return $this;
×
52
        }
53

54
        public function getTitle(): ?string
55
        {
56
                return $this->title;
×
57
        }
58

59
        /**
60
         * @return static
61
         */
62
        public function setClass(string $class, ?string $classSecondary = null): self
1✔
63
        {
64
                $this->class = $class;
1✔
65

66
                if ($classSecondary !== null) {
1✔
67
                        $this->classSecondary = $classSecondary;
×
68
                }
69

70
                return $this;
1✔
71
        }
72

73
        public function getClass(): ?string
74
        {
75
                return $this->class;
×
76
        }
77

78
        /**
79
         * @return static
80
         */
81
        public function setClassSecondary(string $classSecondary): self
82
        {
83
                $this->classSecondary = $classSecondary;
×
84

85
                return $this;
×
86
        }
87

88
        public function getClassSecondary(): string
89
        {
90
                return $this->classSecondary;
×
91
        }
92

93
        /**
94
         * @return static
95
         */
96
        public function setClassInDropdown(string $classInDropdown): self
97
        {
98
                $this->classInDropdown = $classInDropdown;
×
99

100
                return $this;
×
101
        }
102

103
        public function getClassInDropdown(): string
104
        {
105
                return $this->classInDropdown;
×
106
        }
107

108
        /**
109
         * @return static
110
         */
111
        public function setIcon(string $icon): self
1✔
112
        {
113
                $this->icon = $icon;
1✔
114

115
                return $this;
1✔
116
        }
117

118
        public function getIcon(): ?string
119
        {
120
                return $this->icon;
×
121
        }
122

123
        /**
124
         * @return static
125
         */
126
        public function setIconSecondary(string $iconSecondary): self
127
        {
128
                $this->iconSecondary = $iconSecondary;
×
129

130
                return $this;
×
131
        }
132

133
        public function getIconSecondary(): ?string
134
        {
135
                return $this->iconSecondary;
×
136
        }
137

138
        public function getText(): string
139
        {
140
                return $this->text;
×
141
        }
142

143
        /**
144
         * @return static
145
         */
146
        public function setConfirmation(IConfirmation $confirmation): self
147
        {
148
                $this->confirmation = $confirmation;
×
149

150
                return $this;
×
151
        }
152

153
        public function getConfirmationDialog(Row $row): ?string
154
        {
155
                if ($this->confirmation === null) {
×
156
                        return null;
×
157
                }
158

159
                if ($this->confirmation instanceof CallbackConfirmation) {
×
160
                        return ($this->confirmation->getCallback())($row->getItem());
×
161
                }
162

163
                if ($this->confirmation instanceof StringConfirmation) {
×
164
                        $question = $this->grid->getTranslator()->translate($this->confirmation->getQuestion());
×
165

166
                        if ($this->confirmation->getPlaceholderName() === null) {
×
167
                                return $question;
×
168
                        }
169

170
                        return str_replace(
×
171
                                '%s',
×
172
                                $row->getValue($this->confirmation->getPlaceholderName()),
×
173
                                $question
174
                        );
175
                }
176

NEW
177
                throw new DatagridException('Unsupported confirmation');
×
178
        }
179

180
}
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