[ Index ]

PHP Cross Reference of phpBB-3.3.14-deutsch

title

Body

[close]

/vendor/ocramius/proxy-manager/src/ProxyManager/Generator/Util/ -> UniqueIdentifierGenerator.php (source)

   1  <?php
   2  
   3  declare(strict_types=1);
   4  
   5  namespace ProxyManager\Generator\Util;
   6  
   7  /**
   8   * Utility class capable of generating unique
   9   * valid class/property/method identifiers
  10   *
  11   * @author Marco Pivetta <ocramius@gmail.com>
  12   * @license MIT
  13   */
  14  abstract class UniqueIdentifierGenerator
  15  {
  16      const VALID_IDENTIFIER_FORMAT = '/^[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]+$/';
  17      const DEFAULT_IDENTIFIER = 'g';
  18  
  19      /**
  20       * Generates a valid unique identifier from the given name
  21       */
  22      public static function getIdentifier(string $name) : string
  23      {
  24          return str_replace(
  25              '.',
  26              '',
  27              uniqid(
  28                  preg_match(static::VALID_IDENTIFIER_FORMAT, $name)
  29                  ? $name
  30                  : static::DEFAULT_IDENTIFIER,
  31                  true
  32              )
  33          );
  34      }
  35  }


Generated: Mon Nov 25 19:05:08 2024 Cross-referenced by PHPXref 0.7.1