[ Index ]

PHP Cross Reference of DokuWiki

title

Body

[close]

/vendor/simplepie/simplepie/src/ -> Rating.php (source)

   1  <?php
   2  
   3  declare(strict_types=1);
   4  /**
   5   * SimplePie
   6   *
   7   * A PHP-Based RSS and Atom Feed Framework.
   8   * Takes the hard work out of managing a complete RSS/Atom solution.
   9   *
  10   * Copyright (c) 2004-2022, Ryan Parman, Sam Sneddon, Ryan McCue, and contributors
  11   * All rights reserved.
  12   *
  13   * Redistribution and use in source and binary forms, with or without modification, are
  14   * permitted provided that the following conditions are met:
  15   *
  16   *     * Redistributions of source code must retain the above copyright notice, this list of
  17   *       conditions and the following disclaimer.
  18   *
  19   *     * Redistributions in binary form must reproduce the above copyright notice, this list
  20   *       of conditions and the following disclaimer in the documentation and/or other materials
  21   *       provided with the distribution.
  22   *
  23   *     * Neither the name of the SimplePie Team nor the names of its contributors may be used
  24   *       to endorse or promote products derived from this software without specific prior
  25   *       written permission.
  26   *
  27   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
  28   * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
  29   * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDERS
  30   * AND CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  31   * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  32   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  33   * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  34   * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  35   * POSSIBILITY OF SUCH DAMAGE.
  36   *
  37   * @package SimplePie
  38   * @copyright 2004-2016 Ryan Parman, Sam Sneddon, Ryan McCue
  39   * @author Ryan Parman
  40   * @author Sam Sneddon
  41   * @author Ryan McCue
  42   * @link http://simplepie.org/ SimplePie
  43   * @license http://www.opensource.org/licenses/bsd-license.php BSD License
  44   */
  45  
  46  namespace SimplePie;
  47  
  48  /**
  49   * Handles `<media:rating>` or `<itunes:explicit>` tags as defined in Media RSS and iTunes RSS respectively
  50   *
  51   * Used by {@see \SimplePie\Enclosure::get_rating()} and {@see \SimplePie\Enclosure::get_ratings()}
  52   *
  53   * This class can be overloaded with {@see \SimplePie\SimplePie::set_rating_class()}
  54   *
  55   * @package SimplePie
  56   * @subpackage API
  57   */
  58  class Rating
  59  {
  60      /**
  61       * Rating scheme
  62       *
  63       * @var string
  64       * @see get_scheme()
  65       */
  66      public $scheme;
  67  
  68      /**
  69       * Rating value
  70       *
  71       * @var string
  72       * @see get_value()
  73       */
  74      public $value;
  75  
  76      /**
  77       * Constructor, used to input the data
  78       *
  79       * For documentation on all the parameters, see the corresponding
  80       * properties and their accessors
  81       */
  82      public function __construct($scheme = null, $value = null)
  83      {
  84          $this->scheme = $scheme;
  85          $this->value = $value;
  86      }
  87  
  88      /**
  89       * String-ified version
  90       *
  91       * @return string
  92       */
  93      public function __toString()
  94      {
  95          // There is no $this->data here
  96          return md5(serialize($this));
  97      }
  98  
  99      /**
 100       * Get the organizational scheme for the rating
 101       *
 102       * @return string|null
 103       */
 104      public function get_scheme()
 105      {
 106          if ($this->scheme !== null) {
 107              return $this->scheme;
 108          }
 109  
 110          return null;
 111      }
 112  
 113      /**
 114       * Get the value of the rating
 115       *
 116       * @return string|null
 117       */
 118      public function get_value()
 119      {
 120          if ($this->value !== null) {
 121              return $this->value;
 122          }
 123  
 124          return null;
 125      }
 126  }
 127  
 128  class_alias('SimplePie\Rating', 'SimplePie_Rating');