[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/SimplePie/src/ -> Caption.php (source)

   1  <?php
   2  
   3  // SPDX-FileCopyrightText: 2004-2023 Ryan Parman, Sam Sneddon, Ryan McCue
   4  // SPDX-License-Identifier: BSD-3-Clause
   5  
   6  declare(strict_types=1);
   7  
   8  namespace SimplePie;
   9  
  10  /**
  11   * Handles `<media:text>` captions as defined in Media RSS.
  12   *
  13   * Used by {@see \SimplePie\Enclosure::get_caption()} and {@see \SimplePie\Enclosure::get_captions()}
  14   *
  15   * This class can be overloaded with {@see \SimplePie\SimplePie::set_caption_class()}
  16   */
  17  class Caption
  18  {
  19      /**
  20       * Content type
  21       *
  22       * @var ?string
  23       * @see get_type()
  24       */
  25      public $type;
  26  
  27      /**
  28       * Language
  29       *
  30       * @var ?string
  31       * @see get_language()
  32       */
  33      public $lang;
  34  
  35      /**
  36       * Start time
  37       *
  38       * @var ?string
  39       * @see get_starttime()
  40       */
  41      public $startTime;
  42  
  43      /**
  44       * End time
  45       *
  46       * @var ?string
  47       * @see get_endtime()
  48       */
  49      public $endTime;
  50  
  51      /**
  52       * Caption text
  53       *
  54       * @var ?string
  55       * @see get_text()
  56       */
  57      public $text;
  58  
  59      /**
  60       * Constructor, used to input the data
  61       *
  62       * For documentation on all the parameters, see the corresponding
  63       * properties and their accessors
  64       */
  65      public function __construct(
  66          ?string $type = null,
  67          ?string $lang = null,
  68          ?string $startTime = null,
  69          ?string $endTime = null,
  70          ?string $text = null
  71      ) {
  72          $this->type = $type;
  73          $this->lang = $lang;
  74          $this->startTime = $startTime;
  75          $this->endTime = $endTime;
  76          $this->text = $text;
  77      }
  78  
  79      /**
  80       * String-ified version
  81       *
  82       * @return string
  83       */
  84      public function __toString()
  85      {
  86          // There is no $this->data here
  87          return md5(serialize($this));
  88      }
  89  
  90      /**
  91       * Get the end time
  92       *
  93       * @return string|null Time in the format 'hh:mm:ss.SSS'
  94       */
  95      public function get_endtime()
  96      {
  97          if ($this->endTime !== null) {
  98              return $this->endTime;
  99          }
 100  
 101          return null;
 102      }
 103  
 104      /**
 105       * Get the language
 106       *
 107       * @link http://tools.ietf.org/html/rfc3066
 108       * @return string|null Language code as per RFC 3066
 109       */
 110      public function get_language()
 111      {
 112          if ($this->lang !== null) {
 113              return $this->lang;
 114          }
 115  
 116          return null;
 117      }
 118  
 119      /**
 120       * Get the start time
 121       *
 122       * @return string|null Time in the format 'hh:mm:ss.SSS'
 123       */
 124      public function get_starttime()
 125      {
 126          if ($this->startTime !== null) {
 127              return $this->startTime;
 128          }
 129  
 130          return null;
 131      }
 132  
 133      /**
 134       * Get the text of the caption
 135       *
 136       * @return string|null
 137       */
 138      public function get_text()
 139      {
 140          if ($this->text !== null) {
 141              return $this->text;
 142          }
 143  
 144          return null;
 145      }
 146  
 147      /**
 148       * Get the content type (not MIME type)
 149       *
 150       * @return string|null Either 'text' or 'html'
 151       */
 152      public function get_type()
 153      {
 154          if ($this->type !== null) {
 155              return $this->type;
 156          }
 157  
 158          return null;
 159      }
 160  }
 161  
 162  class_alias('SimplePie\Caption', 'SimplePie_Caption');


Generated : Thu Sep 18 08:20:05 2025 Cross-referenced by PHPXref