<?php
namespace PhpOffice\PhpSpreadsheet\Chart;
> use PhpOffice\PhpSpreadsheet\RichText\RichText;
class Title
>
{
/**
* Title Caption.
*
< * @var string
> * @var array|RichText|string
*/
< private $caption;
> private $caption = '';
/**
* Title Layout.
*
< * @var Layout
> * @var ?Layout
*/
private $layout;
/**
* Create a new Title.
*
< * @param null|mixed $caption
> * @param array|RichText|string $caption
*/
< public function __construct($caption = null, ?Layout $layout = null)
> public function __construct($caption = '', ?Layout $layout = null)
{
$this->caption = $caption;
$this->layout = $layout;
}
/**
* Get caption.
*
< * @return string
> * @return array|RichText|string
*/
public function getCaption()
{
return $this->caption;
}
> public function getCaptionText(): string
/**
> {
* Set caption.
> $caption = $this->caption;
*
> if (is_string($caption)) {
* @param string $caption
> return $caption;
*
> }
* @return $this
> if ($caption instanceof RichText) {
*/
> return $caption->getPlainText();
public function setCaption($caption)
> }
{
> $retVal = '';
$this->caption = $caption;
> foreach ($caption as $textx) {
> /** @var RichText|string */
return $this;
> $text = $textx;
}
> if ($text instanceof RichText) {
> $retVal .= $text->getPlainText();
/**
> } else {
* Get Layout.
> $retVal .= $text;
*
> }
* @return Layout
> }
*/
>
public function getLayout()
> return $retVal;
{
> }
return $this->layout;
>
< * @param string $caption
> * @param array|RichText|string $caption
< /**
< * Get Layout.
< *
< * @return Layout
< */
< public function getLayout()
> public function getLayout(): ?Layout