1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Eclipxe\XlsxExporter\Styles; |
6
|
|
|
|
7
|
|
|
use Eclipxe\XlsxExporter\Exceptions\InvalidPropertyValueException; |
8
|
|
|
use Eclipxe\XlsxExporter\Utils\OpenXmlColor; |
|
|
|
|
9
|
|
|
|
10
|
|
|
/** |
11
|
|
|
* @property string $pattern Fill pattern |
12
|
|
|
* @property string $color Fill color |
13
|
|
|
*/ |
14
|
|
|
class Fill extends AbstractStyle |
15
|
|
|
{ |
16
|
|
|
public const SOLID = 'solid'; |
17
|
|
|
|
18
|
|
|
public const NONE = 'none'; |
19
|
|
|
|
20
|
|
|
public const GRAY125 = 'gray125'; |
21
|
|
|
|
22
|
|
|
private const VALUES = [ |
23
|
|
|
self::NONE, |
24
|
|
|
self::GRAY125, |
25
|
|
|
self::SOLID, |
26
|
|
|
]; |
27
|
|
|
|
28
|
26 |
|
protected function properties(): array |
29
|
|
|
{ |
30
|
26 |
|
return [ |
31
|
26 |
|
'color', |
32
|
26 |
|
'pattern', |
33
|
26 |
|
]; |
34
|
|
|
} |
35
|
|
|
|
36
|
5 |
|
public function asXML(): string |
37
|
|
|
{ |
38
|
5 |
|
if (! $this->pattern || $this->pattern == static::NONE || $this->pattern === static::GRAY125) { |
39
|
4 |
|
return '<fill><patternFill patternType="' . $this->pattern . '"/></fill>'; |
40
|
|
|
} |
41
|
3 |
|
return '<fill>' |
42
|
3 |
|
. '<patternFill patternType="' . $this->pattern . '">' |
43
|
3 |
|
. '<fgColor rgb="' . $this->color . '"/>' |
44
|
3 |
|
. '<bgColor rgb="' . $this->color . '"/>' |
45
|
3 |
|
. '</patternFill>' |
46
|
3 |
|
. '</fill>' |
47
|
3 |
|
; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** @param scalar|null $value */ |
51
|
24 |
|
protected function castPattern($value): string |
52
|
|
|
{ |
53
|
24 |
|
$value = (string) $value; |
54
|
24 |
|
if (! in_array($value, self::VALUES, true)) { |
55
|
1 |
|
throw new InvalidPropertyValueException('Invalid fill pattern value', 'pattern', $value); |
56
|
|
|
} |
57
|
24 |
|
return $value; |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
/** @param scalar|null $value */ |
61
|
22 |
|
protected function castColor($value): string |
62
|
|
|
{ |
63
|
22 |
|
if (! is_string($value) && ! is_int($value)) { |
64
|
|
|
$value = (string) $value; |
65
|
|
|
} |
66
|
22 |
|
$color = OpenXmlColor::cast($value); |
67
|
22 |
|
if (false === $color) { |
68
|
1 |
|
throw new InvalidPropertyValueException('Invalid fill color value', 'color', $value); |
69
|
|
|
} |
70
|
22 |
|
return $color; |
71
|
|
|
} |
72
|
|
|
} |
73
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths