Search moodle.org's
Developer Documentation

See Release Notes
Long Term Support Release

  • Bug fixes for general core bugs in 4.1.x will end 13 November 2023 (12 months).
  • Bug fixes for security issues in 4.1.x will end 10 November 2025 (36 months).
  • PHP version: minimum PHP 7.4.0 Note: minimum PHP version has increased since Moodle 4.0. PHP 8.0.x is supported too.

Differences Between: [Versions 310 and 401] [Versions 311 and 401] [Versions 39 and 401] [Versions 400 and 401] [Versions 401 and 402] [Versions 401 and 403]

   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       * Title Layout.
  18       *
  19       * @var ?Layout
  20       */
  21      private $layout;
  22  
  23      /**
  24       * Create a new Title.
  25       *
  26       * @param array|RichText|string $caption
  27       */
  28      public function __construct($caption = '', ?Layout $layout = null)
  29      {
  30          $this->caption = $caption;
  31          $this->layout = $layout;
  32      }
  33  
  34      /**
  35       * Get caption.
  36       *
  37       * @return array|RichText|string
  38       */
  39      public function getCaption()
  40      {
  41          return $this->caption;
  42      }
  43  
  44      public function getCaptionText(): string
  45      {
  46          $caption = $this->caption;
  47          if (is_string($caption)) {
  48              return $caption;
  49          }
  50          if ($caption instanceof RichText) {
  51              return $caption->getPlainText();
  52          }
  53          $retVal = '';
  54          foreach ($caption as $textx) {
  55              /** @var RichText|string */
  56              $text = $textx;
  57              if ($text instanceof RichText) {
  58                  $retVal .= $text->getPlainText();
  59              } else {
  60                  $retVal .= $text;
  61              }
  62          }
  63  
  64          return $retVal;
  65      }
  66  
  67      /**
  68       * Set caption.
  69       *
  70       * @param array|RichText|string $caption
  71       *
  72       * @return $this
  73       */
  74      public function setCaption($caption)
  75      {
  76          $this->caption = $caption;
  77  
  78          return $this;
  79      }
  80  
  81      public function getLayout(): ?Layout
  82      {
  83          return $this->layout;
  84      }
  85  }