Proyectos de Subversion Moodle

Rev

| Ultima modificación | Ver Log |

Rev Autor Línea Nro. Línea
1 efrain 1
<?php
2
 
3
namespace PhpOffice\PhpSpreadsheet\Chart;
4
 
5
use PhpOffice\PhpSpreadsheet\RichText\RichText;
6
 
7
class Title
8
{
9
    /**
10
     * Title Caption.
11
     *
12
     * @var array|RichText|string
13
     */
14
    private $caption = '';
15
 
16
    /**
17
     * Allow overlay of other elements?
18
     *
19
     * @var bool
20
     */
21
    private $overlay = true;
22
 
23
    /**
24
     * Title Layout.
25
     *
26
     * @var ?Layout
27
     */
28
    private $layout;
29
 
30
    /**
31
     * Create a new Title.
32
     *
33
     * @param array|RichText|string $caption
34
     * @param ?Layout $layout
35
     * @param bool $overlay
36
     */
37
    public function __construct($caption = '', ?Layout $layout = null, $overlay = false)
38
    {
39
        $this->caption = $caption;
40
        $this->layout = $layout;
41
        $this->setOverlay($overlay);
42
    }
43
 
44
    /**
45
     * Get caption.
46
     *
47
     * @return array|RichText|string
48
     */
49
    public function getCaption()
50
    {
51
        return $this->caption;
52
    }
53
 
54
    public function getCaptionText(): string
55
    {
56
        $caption = $this->caption;
57
        if (is_string($caption)) {
58
            return $caption;
59
        }
60
        if ($caption instanceof RichText) {
61
            return $caption->getPlainText();
62
        }
63
        $retVal = '';
64
        foreach ($caption as $textx) {
65
            /** @var RichText|string */
66
            $text = $textx;
67
            if ($text instanceof RichText) {
68
                $retVal .= $text->getPlainText();
69
            } else {
70
                $retVal .= $text;
71
            }
72
        }
73
 
74
        return $retVal;
75
    }
76
 
77
    /**
78
     * Set caption.
79
     *
80
     * @param array|RichText|string $caption
81
     *
82
     * @return $this
83
     */
84
    public function setCaption($caption)
85
    {
86
        $this->caption = $caption;
87
 
88
        return $this;
89
    }
90
 
91
    /**
92
     * Get allow overlay of other elements?
93
     *
94
     * @return bool
95
     */
96
    public function getOverlay()
97
    {
98
        return $this->overlay;
99
    }
100
 
101
    /**
102
     * Set allow overlay of other elements?
103
     *
104
     * @param bool $overlay
105
     */
106
    public function setOverlay($overlay): void
107
    {
108
        $this->overlay = $overlay;
109
    }
110
 
111
    public function getLayout(): ?Layout
112
    {
113
        return $this->layout;
114
    }
115
}