[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/SimplePie/src/ -> Credit.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:credit>` as defined in Media RSS
  12   *
  13   * Used by {@see \SimplePie\Enclosure::get_credit()} and {@see \SimplePie\Enclosure::get_credits()}
  14   *
  15   * This class can be overloaded with {@see \SimplePie\SimplePie::set_credit_class()}
  16   */
  17  class Credit
  18  {
  19      /**
  20       * Credited role
  21       *
  22       * @var ?string
  23       * @see get_role()
  24       */
  25      public $role;
  26  
  27      /**
  28       * Organizational scheme
  29       *
  30       * @var ?string
  31       * @see get_scheme()
  32       */
  33      public $scheme;
  34  
  35      /**
  36       * Credited name
  37       *
  38       * @var ?string
  39       * @see get_name()
  40       */
  41      public $name;
  42  
  43      /**
  44       * Constructor, used to input the data
  45       *
  46       * For documentation on all the parameters, see the corresponding
  47       * properties and their accessors
  48       */
  49      public function __construct(
  50          ?string $role = null,
  51          ?string $scheme = null,
  52          ?string $name = null
  53      ) {
  54          $this->role = $role;
  55          $this->scheme = $scheme;
  56          $this->name = $name;
  57      }
  58  
  59      /**
  60       * String-ified version
  61       *
  62       * @return string
  63       */
  64      public function __toString()
  65      {
  66          // There is no $this->data here
  67          return md5(serialize($this));
  68      }
  69  
  70      /**
  71       * Get the role of the person receiving credit
  72       *
  73       * @return string|null
  74       */
  75      public function get_role()
  76      {
  77          if ($this->role !== null) {
  78              return $this->role;
  79          }
  80  
  81          return null;
  82      }
  83  
  84      /**
  85       * Get the organizational scheme
  86       *
  87       * @return string|null
  88       */
  89      public function get_scheme()
  90      {
  91          if ($this->scheme !== null) {
  92              return $this->scheme;
  93          }
  94  
  95          return null;
  96      }
  97  
  98      /**
  99       * Get the credited person/entity's name
 100       *
 101       * @return string|null
 102       */
 103      public function get_name()
 104      {
 105          if ($this->name !== null) {
 106              return $this->name;
 107          }
 108  
 109          return null;
 110      }
 111  }
 112  
 113  class_alias('SimplePie\Credit', 'SimplePie_Credit');


Generated : Wed Sep 17 08:20:04 2025 Cross-referenced by PHPXref