[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/SimplePie/src/ -> Category.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   * Manages all category-related data
  12   *
  13   * Used by {@see \SimplePie\Item::get_category()} and {@see \SimplePie\Item::get_categories()}
  14   *
  15   * This class can be overloaded with {@see \SimplePie\SimplePie::set_category_class()}
  16   */
  17  class Category
  18  {
  19      /**
  20       * Category identifier
  21       *
  22       * @var string|null
  23       * @see get_term
  24       */
  25      public $term;
  26  
  27      /**
  28       * Categorization scheme identifier
  29       *
  30       * @var string|null
  31       * @see get_scheme()
  32       */
  33      public $scheme;
  34  
  35      /**
  36       * Human readable label
  37       *
  38       * @var string|null
  39       * @see get_label()
  40       */
  41      public $label;
  42  
  43      /**
  44       * Category type
  45       *
  46       * category for <category>
  47       * subject for <dc:subject>
  48       *
  49       * @var string|null
  50       * @see get_type()
  51       */
  52      public $type;
  53  
  54      /**
  55       * Constructor, used to input the data
  56       *
  57       * @param string|null $term
  58       * @param string|null $scheme
  59       * @param string|null $label
  60       * @param string|null $type
  61       */
  62      public function __construct(?string $term = null, ?string $scheme = null, ?string $label = null, ?string $type = null)
  63      {
  64          $this->term = $term;
  65          $this->scheme = $scheme;
  66          $this->label = $label;
  67          $this->type = $type;
  68      }
  69  
  70      /**
  71       * String-ified version
  72       *
  73       * @return string
  74       */
  75      public function __toString()
  76      {
  77          // There is no $this->data here
  78          return md5(serialize($this));
  79      }
  80  
  81      /**
  82       * Get the category identifier
  83       *
  84       * @return string|null
  85       */
  86      public function get_term()
  87      {
  88          return $this->term;
  89      }
  90  
  91      /**
  92       * Get the categorization scheme identifier
  93       *
  94       * @return string|null
  95       */
  96      public function get_scheme()
  97      {
  98          return $this->scheme;
  99      }
 100  
 101      /**
 102       * Get the human readable label
 103       *
 104       * @param bool $strict
 105       * @return string|null
 106       */
 107      public function get_label(bool $strict = false)
 108      {
 109          if ($this->label === null && $strict !== true) {
 110              return $this->get_term();
 111          }
 112          return $this->label;
 113      }
 114  
 115      /**
 116       * Get the category type
 117       *
 118       * @return string|null
 119       */
 120      public function get_type()
 121      {
 122          return $this->type;
 123      }
 124  }
 125  
 126  class_alias('SimplePie\Category', 'SimplePie_Category');


Generated : Thu Oct 2 08:20:03 2025 Cross-referenced by PHPXref