Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1441 ariadna 1
<?php
2
 
3
namespace PhpOffice\PhpSpreadsheet\Shared\Escher\DgContainer;
4
 
5
class SpgrContainer
6
{
7
    /**
8
     * Parent Shape Group Container.
9
     */
10
    private ?self $parent = null;
11
 
12
    /**
13
     * Shape Container collection.
14
     */
15
    private array $children = [];
16
 
17
    /**
18
     * Set parent Shape Group Container.
19
     */
20
    public function setParent(?self $parent): void
21
    {
22
        $this->parent = $parent;
23
    }
24
 
25
    /**
26
     * Get the parent Shape Group Container if any.
27
     */
28
    public function getParent(): ?self
29
    {
30
        return $this->parent;
31
    }
32
 
33
    /**
34
     * Add a child. This will be either spgrContainer or spContainer.
35
     *
36
     * @param SpgrContainer|SpgrContainer\SpContainer $child child to be added
37
     */
38
    public function addChild(mixed $child): void
39
    {
40
        $this->children[] = $child;
41
        $child->setParent($this);
42
    }
43
 
44
    /**
45
     * Get collection of Shape Containers.
46
     */
47
    public function getChildren(): array
48
    {
49
        return $this->children;
50
    }
51
 
52
    /**
53
     * Recursively get all spContainers within this spgrContainer.
54
     *
55
     * @return SpgrContainer\SpContainer[]
56
     */
57
    public function getAllSpContainers(): array
58
    {
59
        $allSpContainers = [];
60
 
61
        foreach ($this->children as $child) {
62
            if ($child instanceof self) {
63
                $allSpContainers = array_merge($allSpContainers, $child->getAllSpContainers());
64
            } else {
65
                $allSpContainers[] = $child;
66
            }
67
        }
68
 
69
        return $allSpContainers;
70
    }
71
}