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

PHPOffice / PhpSpreadsheet / 18013950625

25 Sep 2025 04:20PM UTC coverage: 95.867% (+0.3%) from 95.602%
18013950625

push

github

web-flow
Merge pull request #4663 from oleibman/tweakcoveralls

Tweak Coveralls

45116 of 47061 relevant lines covered (95.87%)

373.63 hits per line

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

95.0
/src/PhpSpreadsheet/Worksheet/Drawing/Shadow.php
1
<?php
2

3
namespace PhpOffice\PhpSpreadsheet\Worksheet\Drawing;
4

5
use PhpOffice\PhpSpreadsheet\IComparable;
6
use PhpOffice\PhpSpreadsheet\Style\Color;
7

8
class Shadow implements IComparable
9
{
10
    // Shadow alignment
11
    const SHADOW_BOTTOM = 'b';
12
    const SHADOW_BOTTOM_LEFT = 'bl';
13
    const SHADOW_BOTTOM_RIGHT = 'br';
14
    const SHADOW_CENTER = 'ctr';
15
    const SHADOW_LEFT = 'l';
16
    const SHADOW_TOP = 't';
17
    const SHADOW_TOP_LEFT = 'tl';
18
    const SHADOW_TOP_RIGHT = 'tr';
19

20
    /**
21
     * Visible.
22
     */
23
    private bool $visible;
24

25
    /**
26
     * Blur radius.
27
     *
28
     * Defaults to 6
29
     */
30
    private int $blurRadius;
31

32
    /**
33
     * Shadow distance.
34
     *
35
     * Defaults to 2
36
     */
37
    private int $distance;
38

39
    /**
40
     * Shadow direction (in degrees).
41
     */
42
    private int $direction;
43

44
    /**
45
     * Shadow alignment.
46
     */
47
    private string $alignment;
48

49
    /**
50
     * Color.
51
     */
52
    private Color $color;
53

54
    /**
55
     * Alpha.
56
     */
57
    private int $alpha;
58

59
    /**
60
     * Create a new Shadow.
61
     */
62
    public function __construct()
229✔
63
    {
64
        // Initialise values
65
        $this->visible = false;
229✔
66
        $this->blurRadius = 6;
229✔
67
        $this->distance = 2;
229✔
68
        $this->direction = 0;
229✔
69
        $this->alignment = self::SHADOW_BOTTOM_RIGHT;
229✔
70
        $this->color = new Color(Color::COLOR_BLACK);
229✔
71
        $this->alpha = 50;
229✔
72
    }
73

74
    /**
75
     * Get Visible.
76
     */
77
    public function getVisible(): bool
53✔
78
    {
79
        return $this->visible;
53✔
80
    }
81

82
    /**
83
     * Set Visible.
84
     *
85
     * @return $this
86
     */
87
    public function setVisible(bool $visible): static
18✔
88
    {
89
        $this->visible = $visible;
18✔
90

91
        return $this;
18✔
92
    }
93

94
    /**
95
     * Get Blur radius.
96
     */
97
    public function getBlurRadius(): int
6✔
98
    {
99
        return $this->blurRadius;
6✔
100
    }
101

102
    /**
103
     * Set Blur radius.
104
     *
105
     * @return $this
106
     */
107
    public function setBlurRadius(int $blurRadius): static
3✔
108
    {
109
        $this->blurRadius = $blurRadius;
3✔
110

111
        return $this;
3✔
112
    }
113

114
    /**
115
     * Get Shadow distance.
116
     */
117
    public function getDistance(): int
6✔
118
    {
119
        return $this->distance;
6✔
120
    }
121

122
    /**
123
     * Set Shadow distance.
124
     *
125
     * @return $this
126
     */
127
    public function setDistance(int $distance): static
3✔
128
    {
129
        $this->distance = $distance;
3✔
130

131
        return $this;
3✔
132
    }
133

134
    /**
135
     * Get Shadow direction (in degrees).
136
     */
137
    public function getDirection(): int
6✔
138
    {
139
        return $this->direction;
6✔
140
    }
141

142
    /**
143
     * Set Shadow direction (in degrees).
144
     *
145
     * @return $this
146
     */
147
    public function setDirection(int $direction): static
18✔
148
    {
149
        $this->direction = $direction;
18✔
150

151
        return $this;
18✔
152
    }
153

154
    /**
155
     * Get Shadow alignment.
156
     */
157
    public function getAlignment(): string
6✔
158
    {
159
        return $this->alignment;
6✔
160
    }
161

162
    /**
163
     * Set Shadow alignment.
164
     *
165
     * @return $this
166
     */
167
    public function setAlignment(string $alignment): static
3✔
168
    {
169
        $this->alignment = $alignment;
3✔
170

171
        return $this;
3✔
172
    }
173

174
    /**
175
     * Get Color.
176
     */
177
    public function getColor(): Color
7✔
178
    {
179
        return $this->color;
7✔
180
    }
181

182
    /**
183
     * Set Color.
184
     *
185
     * @return $this
186
     */
187
    public function setColor(Color $color): static
×
188
    {
189
        $this->color = $color;
×
190

191
        return $this;
×
192
    }
193

194
    /**
195
     * Get Alpha.
196
     */
197
    public function getAlpha(): int
7✔
198
    {
199
        return $this->alpha;
7✔
200
    }
201

202
    /**
203
     * Set Alpha.
204
     *
205
     * @return $this
206
     */
207
    public function setAlpha(int $alpha): static
3✔
208
    {
209
        $this->alpha = $alpha;
3✔
210

211
        return $this;
3✔
212
    }
213

214
    /**
215
     * Get hash code.
216
     *
217
     * @return string Hash code
218
     */
219
    public function getHashCode(): string
54✔
220
    {
221
        return md5(
54✔
222
            ($this->visible ? 't' : 'f')
54✔
223
            . $this->blurRadius
54✔
224
            . $this->distance
54✔
225
            . $this->direction
54✔
226
            . $this->alignment
54✔
227
            . $this->color->getHashCode()
54✔
228
            . $this->alpha
54✔
229
            . __CLASS__
54✔
230
        );
54✔
231
    }
232

233
    /**
234
     * Implement PHP __clone to create a deep clone, not just a shallow copy.
235
     */
236
    public function __clone()
8✔
237
    {
238
        $vars = get_object_vars($this);
8✔
239
        foreach ($vars as $key => $value) {
8✔
240
            if (is_object($value)) {
8✔
241
                $this->$key = clone $value;
8✔
242
            } else {
243
                $this->$key = $value;
8✔
244
            }
245
        }
246
    }
247
}
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