[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/SimplePie/src/ -> Restriction.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:restriction>` as defined in Media RSS
  12   *
  13   * Used by {@see \SimplePie\Enclosure::get_restriction()} and {@see \SimplePie\Enclosure::get_restrictions()}
  14   *
  15   * This class can be overloaded with {@see \SimplePie\SimplePie::set_restriction_class()}
  16   */
  17  class Restriction
  18  {
  19      public const RELATIONSHIP_ALLOW = 'allow';
  20      public const RELATIONSHIP_DENY = 'deny';
  21  
  22      /**
  23       * Relationship ('allow'/'deny')
  24       *
  25       * @var self::RELATIONSHIP_*|null
  26       * @see get_relationship()
  27       */
  28      public $relationship;
  29  
  30      /**
  31       * Type of restriction
  32       *
  33       * @var string|null
  34       * @see get_type()
  35       */
  36      public $type;
  37  
  38      /**
  39       * Restricted values
  40       *
  41       * @var string|null
  42       * @see get_value()
  43       */
  44      public $value;
  45  
  46      /**
  47       * Constructor, used to input the data
  48       *
  49       * For documentation on all the parameters, see the corresponding
  50       * properties and their accessors
  51       *
  52       * @param ?self::RELATIONSHIP_* $relationship
  53       */
  54      public function __construct(?string $relationship = null, ?string $type = null, ?string $value = null)
  55      {
  56          $this->relationship = $relationship;
  57          $this->type = $type;
  58          $this->value = $value;
  59      }
  60  
  61      /**
  62       * String-ified version
  63       *
  64       * @return string
  65       */
  66      public function __toString()
  67      {
  68          // There is no $this->data here
  69          return md5(serialize($this));
  70      }
  71  
  72      /**
  73       * Get the relationship
  74       *
  75       * @return ?self::RELATIONSHIP_*
  76       */
  77      public function get_relationship()
  78      {
  79          if ($this->relationship !== null) {
  80              return $this->relationship;
  81          }
  82  
  83          return null;
  84      }
  85  
  86      /**
  87       * Get the type
  88       *
  89       * @return string|null
  90       */
  91      public function get_type()
  92      {
  93          if ($this->type !== null) {
  94              return $this->type;
  95          }
  96  
  97          return null;
  98      }
  99  
 100      /**
 101       * Get the list of restricted things
 102       *
 103       * @return string|null
 104       */
 105      public function get_value()
 106      {
 107          if ($this->value !== null) {
 108              return $this->value;
 109          }
 110  
 111          return null;
 112      }
 113  }
 114  
 115  class_alias('SimplePie\Restriction', 'SimplePie_Restriction');


Generated : Fri Oct 10 08:20:03 2025 Cross-referenced by PHPXref