Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
24 / 24 |
|
100.00% |
12 / 12 |
CRAP | |
100.00% |
1 / 1 |
| Fill | |
100.00% |
24 / 24 |
|
100.00% |
12 / 12 |
12 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| getFillType | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setFillType | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| getRotation | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setRotation | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| getStartColor | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setStartColor | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| getEndColor | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setEndColor | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| getHashCode | |
100.00% |
7 / 7 |
|
100.00% |
1 / 1 |
1 | |||
| getHashIndex | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setHashIndex | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * This file is part of PHPPresentation - A pure PHP library for reading and writing |
| 4 | * presentations documents. |
| 5 | * |
| 6 | * PHPPresentation is free software distributed under the terms of the GNU Lesser |
| 7 | * General Public License version 3 as published by the Free Software Foundation. |
| 8 | * |
| 9 | * For the full copyright and license information, please read the LICENSE |
| 10 | * file that was distributed with this source code. For the full list of |
| 11 | * contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors. |
| 12 | * |
| 13 | * @see https://github.com/PHPOffice/PHPPresentation |
| 14 | * |
| 15 | * @license http://www.gnu.org/licenses/lgpl.txt LGPL version 3 |
| 16 | */ |
| 17 | |
| 18 | declare(strict_types=1); |
| 19 | |
| 20 | namespace PhpOffice\PhpPresentation\Style; |
| 21 | |
| 22 | use PhpOffice\PhpPresentation\ComparableInterface; |
| 23 | |
| 24 | class Fill implements ComparableInterface |
| 25 | { |
| 26 | // Fill types |
| 27 | public const FILL_NONE = 'none'; |
| 28 | public const FILL_SOLID = 'solid'; |
| 29 | public const FILL_GRADIENT_LINEAR = 'linear'; |
| 30 | public const FILL_GRADIENT_PATH = 'path'; |
| 31 | public const FILL_PATTERN_DARKDOWN = 'darkDown'; |
| 32 | public const FILL_PATTERN_DARKGRAY = 'darkGray'; |
| 33 | public const FILL_PATTERN_DARKGRID = 'darkGrid'; |
| 34 | public const FILL_PATTERN_DARKHORIZONTAL = 'darkHorizontal'; |
| 35 | public const FILL_PATTERN_DARKTRELLIS = 'darkTrellis'; |
| 36 | public const FILL_PATTERN_DARKUP = 'darkUp'; |
| 37 | public const FILL_PATTERN_DARKVERTICAL = 'darkVertical'; |
| 38 | public const FILL_PATTERN_GRAY0625 = 'gray0625'; |
| 39 | public const FILL_PATTERN_GRAY125 = 'gray125'; |
| 40 | public const FILL_PATTERN_LIGHTDOWN = 'lightDown'; |
| 41 | public const FILL_PATTERN_LIGHTGRAY = 'lightGray'; |
| 42 | public const FILL_PATTERN_LIGHTGRID = 'lightGrid'; |
| 43 | public const FILL_PATTERN_LIGHTHORIZONTAL = 'lightHorizontal'; |
| 44 | public const FILL_PATTERN_LIGHTTRELLIS = 'lightTrellis'; |
| 45 | public const FILL_PATTERN_LIGHTUP = 'lightUp'; |
| 46 | public const FILL_PATTERN_LIGHTVERTICAL = 'lightVertical'; |
| 47 | public const FILL_PATTERN_MEDIUMGRAY = 'mediumGray'; |
| 48 | |
| 49 | /** |
| 50 | * Fill type. |
| 51 | * |
| 52 | * @var string |
| 53 | */ |
| 54 | private $fillType = self::FILL_NONE; |
| 55 | |
| 56 | /** |
| 57 | * Rotation. |
| 58 | * |
| 59 | * @var float |
| 60 | */ |
| 61 | private $rotation = 0.0; |
| 62 | |
| 63 | /** |
| 64 | * Start color. |
| 65 | * |
| 66 | * @var Color |
| 67 | */ |
| 68 | private $startColor; |
| 69 | |
| 70 | /** |
| 71 | * End color. |
| 72 | * |
| 73 | * @var Color |
| 74 | */ |
| 75 | private $endColor; |
| 76 | |
| 77 | /** |
| 78 | * Hash index. |
| 79 | * |
| 80 | * @var int |
| 81 | */ |
| 82 | private $hashIndex; |
| 83 | |
| 84 | /** |
| 85 | * Create a new \PhpOffice\PhpPresentation\Style\Fill. |
| 86 | */ |
| 87 | public function __construct() |
| 88 | { |
| 89 | $this->startColor = new Color(Color::COLOR_BLACK); |
| 90 | $this->endColor = new Color(Color::COLOR_WHITE); |
| 91 | } |
| 92 | |
| 93 | /** |
| 94 | * Get Fill Type. |
| 95 | */ |
| 96 | public function getFillType(): string |
| 97 | { |
| 98 | return $this->fillType; |
| 99 | } |
| 100 | |
| 101 | /** |
| 102 | * Set Fill Type. |
| 103 | * |
| 104 | * @param string $pValue Fill type |
| 105 | */ |
| 106 | public function setFillType(string $pValue = self::FILL_NONE): self |
| 107 | { |
| 108 | $this->fillType = $pValue; |
| 109 | |
| 110 | return $this; |
| 111 | } |
| 112 | |
| 113 | /** |
| 114 | * Get Rotation. |
| 115 | */ |
| 116 | public function getRotation(): float |
| 117 | { |
| 118 | return $this->rotation; |
| 119 | } |
| 120 | |
| 121 | /** |
| 122 | * Set Rotation. |
| 123 | */ |
| 124 | public function setRotation(float $pValue = 0): self |
| 125 | { |
| 126 | $this->rotation = $pValue; |
| 127 | |
| 128 | return $this; |
| 129 | } |
| 130 | |
| 131 | /** |
| 132 | * Get Start Color. |
| 133 | */ |
| 134 | public function getStartColor(): Color |
| 135 | { |
| 136 | // It's a get but it may lead to a modified color which we won't detect but in which case we must bind. |
| 137 | // So bind as an assurance. |
| 138 | return $this->startColor; |
| 139 | } |
| 140 | |
| 141 | /** |
| 142 | * Set Start Color. |
| 143 | */ |
| 144 | public function setStartColor(Color $pValue): self |
| 145 | { |
| 146 | $this->startColor = $pValue; |
| 147 | |
| 148 | return $this; |
| 149 | } |
| 150 | |
| 151 | /** |
| 152 | * Get End Color. |
| 153 | */ |
| 154 | public function getEndColor(): Color |
| 155 | { |
| 156 | // It's a get but it may lead to a modified color which we won't detect but in which case we must bind. |
| 157 | // So bind as an assurance. |
| 158 | return $this->endColor; |
| 159 | } |
| 160 | |
| 161 | /** |
| 162 | * Set End Color. |
| 163 | */ |
| 164 | public function setEndColor(Color $pValue): self |
| 165 | { |
| 166 | $this->endColor = $pValue; |
| 167 | |
| 168 | return $this; |
| 169 | } |
| 170 | |
| 171 | /** |
| 172 | * Get hash code. |
| 173 | * |
| 174 | * @return string Hash code |
| 175 | */ |
| 176 | public function getHashCode(): string |
| 177 | { |
| 178 | return md5( |
| 179 | $this->getFillType() |
| 180 | . $this->getRotation() |
| 181 | . $this->getStartColor()->getHashCode() |
| 182 | . $this->getEndColor()->getHashCode() |
| 183 | . __CLASS__ |
| 184 | ); |
| 185 | } |
| 186 | |
| 187 | /** |
| 188 | * Get hash index. |
| 189 | * |
| 190 | * Note that this index may vary during script execution! Only reliable moment is |
| 191 | * while doing a write of a workbook and when changes are not allowed. |
| 192 | * |
| 193 | * @return null|int Hash index |
| 194 | */ |
| 195 | public function getHashIndex(): ?int |
| 196 | { |
| 197 | return $this->hashIndex; |
| 198 | } |
| 199 | |
| 200 | /** |
| 201 | * Set hash index. |
| 202 | * |
| 203 | * Note that this index may vary during script execution! Only reliable moment is |
| 204 | * while doing a write of a workbook and when changes are not allowed. |
| 205 | * |
| 206 | * @param int $value Hash index |
| 207 | * |
| 208 | * @return $this |
| 209 | */ |
| 210 | public function setHashIndex(int $value) |
| 211 | { |
| 212 | $this->hashIndex = $value; |
| 213 | |
| 214 | return $this; |
| 215 | } |
| 216 | } |