Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
27 / 27 |
|
100.00% |
17 / 17 |
CRAP | |
100.00% |
1 / 1 |
| PlotArea | |
100.00% |
27 / 27 |
|
100.00% |
17 / 17 |
19 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| __clone | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| getType | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
2 | |||
| setType | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| getAxisX | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getAxisY | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getOffsetX | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setOffsetX | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| getOffsetY | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setOffsetY | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| getWidth | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setWidth | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| getHeight | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| setHeight | |
100.00% |
2 / 2 |
|
100.00% |
1 / 1 |
1 | |||
| getHashCode | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
2 | |||
| 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\Shape\Chart; |
| 21 | |
| 22 | use PhpOffice\PhpPresentation\ComparableInterface; |
| 23 | use PhpOffice\PhpPresentation\Exception\UndefinedChartTypeException; |
| 24 | use PhpOffice\PhpPresentation\Shape\Chart\Type\AbstractType; |
| 25 | |
| 26 | /** |
| 27 | * \PhpOffice\PhpPresentation\Shape\Chart\PlotArea. |
| 28 | */ |
| 29 | class PlotArea implements ComparableInterface |
| 30 | { |
| 31 | /** |
| 32 | * Type. |
| 33 | * |
| 34 | * @var null|AbstractType |
| 35 | */ |
| 36 | private $type; |
| 37 | |
| 38 | /** |
| 39 | * Axis X. |
| 40 | * |
| 41 | * @var Axis |
| 42 | */ |
| 43 | private $axisX; |
| 44 | |
| 45 | /** |
| 46 | * Axis Y. |
| 47 | * |
| 48 | * @var Axis |
| 49 | */ |
| 50 | private $axisY; |
| 51 | |
| 52 | /** |
| 53 | * OffsetX (as a fraction of the chart). |
| 54 | * |
| 55 | * @var float |
| 56 | */ |
| 57 | private $offsetX = 0; |
| 58 | |
| 59 | /** |
| 60 | * OffsetY (as a fraction of the chart). |
| 61 | * |
| 62 | * @var float |
| 63 | */ |
| 64 | private $offsetY = 0; |
| 65 | |
| 66 | /** |
| 67 | * Width (as a fraction of the chart). |
| 68 | * |
| 69 | * @var float |
| 70 | */ |
| 71 | private $width = 0; |
| 72 | |
| 73 | /** |
| 74 | * Height (as a fraction of the chart). |
| 75 | * |
| 76 | * @var float |
| 77 | */ |
| 78 | private $height = 0; |
| 79 | |
| 80 | public function __construct() |
| 81 | { |
| 82 | $this->axisX = new Axis(); |
| 83 | $this->axisY = new Axis(); |
| 84 | } |
| 85 | |
| 86 | public function __clone() |
| 87 | { |
| 88 | $this->axisX = clone $this->axisX; |
| 89 | $this->axisY = clone $this->axisY; |
| 90 | } |
| 91 | |
| 92 | public function getType(): AbstractType |
| 93 | { |
| 94 | if (null === $this->type) { |
| 95 | throw new UndefinedChartTypeException(); |
| 96 | } |
| 97 | |
| 98 | return $this->type; |
| 99 | } |
| 100 | |
| 101 | public function setType(AbstractType $value): self |
| 102 | { |
| 103 | $this->type = $value; |
| 104 | |
| 105 | return $this; |
| 106 | } |
| 107 | |
| 108 | /** |
| 109 | * Get Axis X. |
| 110 | */ |
| 111 | public function getAxisX(): Axis |
| 112 | { |
| 113 | return $this->axisX; |
| 114 | } |
| 115 | |
| 116 | /** |
| 117 | * Get Axis Y. |
| 118 | */ |
| 119 | public function getAxisY(): Axis |
| 120 | { |
| 121 | return $this->axisY; |
| 122 | } |
| 123 | |
| 124 | /** |
| 125 | * Get OffsetX (as a fraction of the chart). |
| 126 | */ |
| 127 | public function getOffsetX(): float |
| 128 | { |
| 129 | return $this->offsetX; |
| 130 | } |
| 131 | |
| 132 | /** |
| 133 | * Set OffsetX (as a fraction of the chart). |
| 134 | */ |
| 135 | public function setOffsetX(float $pValue = 0): self |
| 136 | { |
| 137 | $this->offsetX = $pValue; |
| 138 | |
| 139 | return $this; |
| 140 | } |
| 141 | |
| 142 | /** |
| 143 | * Get OffsetY (as a fraction of the chart). |
| 144 | */ |
| 145 | public function getOffsetY(): float |
| 146 | { |
| 147 | return $this->offsetY; |
| 148 | } |
| 149 | |
| 150 | /** |
| 151 | * Set OffsetY (as a fraction of the chart). |
| 152 | */ |
| 153 | public function setOffsetY(float $pValue = 0): self |
| 154 | { |
| 155 | $this->offsetY = $pValue; |
| 156 | |
| 157 | return $this; |
| 158 | } |
| 159 | |
| 160 | /** |
| 161 | * Get Width (as a fraction of the chart). |
| 162 | */ |
| 163 | public function getWidth(): float |
| 164 | { |
| 165 | return $this->width; |
| 166 | } |
| 167 | |
| 168 | /** |
| 169 | * Set Width (as a fraction of the chart). |
| 170 | */ |
| 171 | public function setWidth(int $pValue = 0): self |
| 172 | { |
| 173 | $this->width = $pValue; |
| 174 | |
| 175 | return $this; |
| 176 | } |
| 177 | |
| 178 | /** |
| 179 | * Get Height (as a fraction of the chart). |
| 180 | */ |
| 181 | public function getHeight(): float |
| 182 | { |
| 183 | return $this->height; |
| 184 | } |
| 185 | |
| 186 | /** |
| 187 | * Set Height (as a fraction of the chart). |
| 188 | */ |
| 189 | public function setHeight(float $value = 0): self |
| 190 | { |
| 191 | $this->height = $value; |
| 192 | |
| 193 | return $this; |
| 194 | } |
| 195 | |
| 196 | /** |
| 197 | * Get hash code. |
| 198 | * |
| 199 | * @return string Hash code |
| 200 | */ |
| 201 | public function getHashCode(): string |
| 202 | { |
| 203 | return md5((null === $this->type ? 'null' : $this->type->getHashCode()) . $this->axisX->getHashCode() . $this->axisY->getHashCode() . $this->offsetX . $this->offsetY . $this->width . $this->height . __CLASS__); |
| 204 | } |
| 205 | |
| 206 | /** |
| 207 | * Hash index. |
| 208 | * |
| 209 | * @var int |
| 210 | */ |
| 211 | private $hashIndex; |
| 212 | |
| 213 | /** |
| 214 | * Get hash index. |
| 215 | * |
| 216 | * Note that this index may vary during script execution! Only reliable moment is |
| 217 | * while doing a write of a workbook and when changes are not allowed. |
| 218 | * |
| 219 | * @return null|int Hash index |
| 220 | */ |
| 221 | public function getHashIndex(): ?int |
| 222 | { |
| 223 | return $this->hashIndex; |
| 224 | } |
| 225 | |
| 226 | /** |
| 227 | * Set hash index. |
| 228 | * |
| 229 | * Note that this index may vary during script execution! Only reliable moment is |
| 230 | * while doing a write of a workbook and when changes are not allowed. |
| 231 | * |
| 232 | * @param int $value Hash index |
| 233 | * |
| 234 | * @return PlotArea |
| 235 | */ |
| 236 | public function setHashIndex(int $value) |
| 237 | { |
| 238 | $this->hashIndex = $value; |
| 239 | |
| 240 | return $this; |
| 241 | } |
| 242 | } |