Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
40 / 40
100.00% covered (success)
100.00%
14 / 14
CRAP
100.00% covered (success)
100.00%
1 / 1
Group
100.00% covered (success)
100.00%
40 / 40
100.00% covered (success)
100.00%
14 / 14
18
100.00% covered (success)
100.00%
1 / 1
 __construct
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getOffsetX
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
2
 setOffsetX
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getOffsetY
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
2
 setOffsetY
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 getExtentX
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
2
 getExtentY
100.00% covered (success)
100.00%
5 / 5
100.00% covered (success)
100.00%
1 / 1
2
 setWidth
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 setHeight
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 createRichTextShape
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
 createLineShape
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
 createChartShape
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
 createDrawingShape
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
 createTableShape
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
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
18declare(strict_types=1);
19
20namespace PhpOffice\PhpPresentation\Shape;
21
22use PhpOffice\PhpPresentation\AbstractShape;
23use PhpOffice\PhpPresentation\GeometryCalculator;
24use PhpOffice\PhpPresentation\ShapeContainerInterface;
25use PhpOffice\PhpPresentation\Traits\ShapeCollection;
26
27class Group extends AbstractShape implements ShapeContainerInterface
28{
29    use ShapeCollection;
30
31    /**
32     * Extent X.
33     *
34     * @var int
35     */
36    protected $extentX;
37
38    /**
39     * Extent Y.
40     *
41     * @var int
42     */
43    protected $extentY;
44
45    public function __construct()
46    {
47        parent::__construct();
48    }
49
50    /**
51     * Get X Offset.
52     */
53    public function getOffsetX(): int
54    {
55        if (empty($this->offsetX)) {
56            $offsets = GeometryCalculator::calculateOffsets($this);
57            $this->offsetX = $offsets[GeometryCalculator::X];
58            $this->offsetY = $offsets[GeometryCalculator::Y];
59        }
60
61        return $this->offsetX;
62    }
63
64    /**
65     * Ignores setting the X Offset, preserving the default behavior.
66     *
67     * @return $this
68     */
69    public function setOffsetX(int $pValue = 0)
70    {
71        return $this;
72    }
73
74    /**
75     * Get Y Offset.
76     */
77    public function getOffsetY(): int
78    {
79        if (empty($this->offsetY)) {
80            $offsets = GeometryCalculator::calculateOffsets($this);
81            $this->offsetX = $offsets[GeometryCalculator::X];
82            $this->offsetY = $offsets[GeometryCalculator::Y];
83        }
84
85        return $this->offsetY;
86    }
87
88    /**
89     * Ignores setting the Y Offset, preserving the default behavior.
90     *
91     * @return $this
92     */
93    public function setOffsetY(int $pValue = 0)
94    {
95        return $this;
96    }
97
98    /**
99     * Get X Extent.
100     */
101    public function getExtentX(): int
102    {
103        if (null === $this->extentX) {
104            $extents = GeometryCalculator::calculateExtents($this);
105            $this->extentX = $extents[GeometryCalculator::X] - $this->getOffsetX();
106            $this->extentY = $extents[GeometryCalculator::Y] - $this->getOffsetY();
107        }
108
109        return $this->extentX;
110    }
111
112    /**
113     * Get Y Extent.
114     */
115    public function getExtentY(): int
116    {
117        if (null === $this->extentY) {
118            $extents = GeometryCalculator::calculateExtents($this);
119            $this->extentX = $extents[GeometryCalculator::X] - $this->getOffsetX();
120            $this->extentY = $extents[GeometryCalculator::Y] - $this->getOffsetY();
121        }
122
123        return $this->extentY;
124    }
125
126    /**
127     * Ignores setting the width, preserving the default behavior.
128     *
129     * @return self
130     */
131    public function setWidth(int $pValue = 0)
132    {
133        return $this;
134    }
135
136    /**
137     * Ignores setting the height, preserving the default behavior.
138     *
139     * @return $this
140     */
141    public function setHeight(int $pValue = 0)
142    {
143        return $this;
144    }
145
146    /**
147     * Create rich text shape.
148     */
149    public function createRichTextShape(): RichText
150    {
151        $shape = new RichText();
152        $this->addShape($shape);
153
154        return $shape;
155    }
156
157    /**
158     * Create line shape.
159     *
160     * @param int $fromX Starting point x offset
161     * @param int $fromY Starting point y offset
162     * @param int $toX Ending point x offset
163     * @param int $toY Ending point y offset
164     */
165    public function createLineShape(int $fromX, int $fromY, int $toX, int $toY): Line
166    {
167        $shape = new Line($fromX, $fromY, $toX, $toY);
168        $this->addShape($shape);
169
170        return $shape;
171    }
172
173    /**
174     * Create chart shape.
175     */
176    public function createChartShape(): Chart
177    {
178        $shape = new Chart();
179        $this->addShape($shape);
180
181        return $shape;
182    }
183
184    /**
185     * Create drawing shape.
186     */
187    public function createDrawingShape(): Drawing\File
188    {
189        $shape = new Drawing\File();
190        $this->addShape($shape);
191
192        return $shape;
193    }
194
195    /**
196     * Create table shape.
197     *
198     * @param int $columns Number of columns
199     */
200    public function createTableShape(int $columns = 1): Table
201    {
202        $shape = new Table($columns);
203        $this->addShape($shape);
204
205        return $shape;
206    }
207}