Search moodle.org's
Developer Documentation

See Release Notes

  • Bug fixes for general core bugs in 4.3.x will end 7 October 2024 (12 months).
  • Bug fixes for security issues in 4.3.x will end 21 April 2025 (18 months).
  • PHP version: minimum PHP 8.0.0 Note: minimum PHP version has increased since Moodle 4.1. PHP 8.2.x is supported too.
   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:restriction>` as defined in Media RSS
  50   *
  51   * Used by {@see \SimplePie\Enclosure::get_restriction()} and {@see \SimplePie\Enclosure::get_restrictions()}
  52   *
  53   * This class can be overloaded with {@see \SimplePie\SimplePie::set_restriction_class()}
  54   *
  55   * @package SimplePie
  56   * @subpackage API
  57   */
  58  class Restriction
  59  {
  60      /**
  61       * Relationship ('allow'/'deny')
  62       *
  63       * @var string
  64       * @see get_relationship()
  65       */
  66      public $relationship;
  67  
  68      /**
  69       * Type of restriction
  70       *
  71       * @var string
  72       * @see get_type()
  73       */
  74      public $type;
  75  
  76      /**
  77       * Restricted values
  78       *
  79       * @var string
  80       * @see get_value()
  81       */
  82      public $value;
  83  
  84      /**
  85       * Constructor, used to input the data
  86       *
  87       * For documentation on all the parameters, see the corresponding
  88       * properties and their accessors
  89       */
  90      public function __construct($relationship = null, $type = null, $value = null)
  91      {
  92          $this->relationship = $relationship;
  93          $this->type = $type;
  94          $this->value = $value;
  95      }
  96  
  97      /**
  98       * String-ified version
  99       *
 100       * @return string
 101       */
 102      public function __toString()
 103      {
 104          // There is no $this->data here
 105          return md5(serialize($this));
 106      }
 107  
 108      /**
 109       * Get the relationship
 110       *
 111       * @return string|null Either 'allow' or 'deny'
 112       */
 113      public function get_relationship()
 114      {
 115          if ($this->relationship !== null) {
 116              return $this->relationship;
 117          }
 118  
 119          return null;
 120      }
 121  
 122      /**
 123       * Get the type
 124       *
 125       * @return string|null
 126       */
 127      public function get_type()
 128      {
 129          if ($this->type !== null) {
 130              return $this->type;
 131          }
 132  
 133          return null;
 134      }
 135  
 136      /**
 137       * Get the list of restricted things
 138       *
 139       * @return string|null
 140       */
 141      public function get_value()
 142      {
 143          if ($this->value !== null) {
 144              return $this->value;
 145          }
 146  
 147          return null;
 148      }
 149  }
 150  
 151  class_alias('SimplePie\Restriction', 'SimplePie_Restriction');