[ Index ]

PHP Cross Reference of WordPress Trunk (Updated Daily)

Search

title

Body

[close]

/wp-includes/SimplePie/src/Cache/ -> CallableNameFilter.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\Cache;
   9  
  10  /**
  11   * Creating a cache filename with callables
  12   */
  13  final class CallableNameFilter implements NameFilter
  14  {
  15      /**
  16       * @var callable(string): string
  17       */
  18      private $callable;
  19  
  20      /**
  21       * @param callable(string): string $callable
  22       */
  23      public function __construct(callable $callable)
  24      {
  25          $this->callable = $callable;
  26      }
  27  
  28      /**
  29       * Method to create cache filename with.
  30       *
  31       * The returning name MUST follow the rules for keys in PSR-16.
  32       *
  33       * @link https://www.php-fig.org/psr/psr-16/
  34       *
  35       * The returning name MUST be a string of at least one character
  36       * that uniquely identifies a cached item, MUST only contain the
  37       * characters A-Z, a-z, 0-9, _, and . in any order in UTF-8 encoding
  38       * and MUST not longer then 64 characters. The following characters
  39       * are reserved for future extensions and MUST NOT be used: {}()/\@:
  40       *
  41       * A provided implementing library MAY support additional characters
  42       * and encodings or longer lengths, but MUST support at least that
  43       * minimum.
  44       *
  45       * @param string $name The name for the cache will be most likely an url with query string
  46       *
  47       * @return string the new cache name
  48       */
  49      public function filter(string $name): string
  50      {
  51          return call_user_func($this->callable, $name);
  52      }
  53  }


Generated : Wed Sep 17 08:20:04 2025 Cross-referenced by PHPXref