[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/SimplePie/src/ -> Rating.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:rating>` or `<itunes:explicit>` tags as defined in Media RSS and iTunes RSS respectively
  12   *
  13   * Used by {@see \SimplePie\Enclosure::get_rating()} and {@see \SimplePie\Enclosure::get_ratings()}
  14   *
  15   * This class can be overloaded with {@see \SimplePie\SimplePie::set_rating_class()}
  16   */
  17  class Rating
  18  {
  19      /**
  20       * Rating scheme
  21       *
  22       * @var ?string
  23       * @see get_scheme()
  24       */
  25      public $scheme;
  26  
  27      /**
  28       * Rating value
  29       *
  30       * @var ?string
  31       * @see get_value()
  32       */
  33      public $value;
  34  
  35      /**
  36       * Constructor, used to input the data
  37       *
  38       * For documentation on all the parameters, see the corresponding
  39       * properties and their accessors
  40       */
  41      public function __construct(
  42          ?string $scheme = null,
  43          ?string $value = null
  44      ) {
  45          $this->scheme = $scheme;
  46          $this->value = $value;
  47      }
  48  
  49      /**
  50       * String-ified version
  51       *
  52       * @return string
  53       */
  54      public function __toString()
  55      {
  56          // There is no $this->data here
  57          return md5(serialize($this));
  58      }
  59  
  60      /**
  61       * Get the organizational scheme for the rating
  62       *
  63       * @return string|null
  64       */
  65      public function get_scheme()
  66      {
  67          if ($this->scheme !== null) {
  68              return $this->scheme;
  69          }
  70  
  71          return null;
  72      }
  73  
  74      /**
  75       * Get the value of the rating
  76       *
  77       * @return string|null
  78       */
  79      public function get_value()
  80      {
  81          if ($this->value !== null) {
  82              return $this->value;
  83          }
  84  
  85          return null;
  86      }
  87  }
  88  
  89  class_alias('SimplePie\Rating', 'SimplePie_Rating');


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