You are here

class NameGenerator in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 vendor/phpspec/prophecy/src/Prophecy/Doubler/NameGenerator.php \Prophecy\Doubler\NameGenerator

Name generator. Generates classname for double.

@author Konstantin Kudryashov <ever.zet@gmail.com>

Hierarchy

Expanded class hierarchy of NameGenerator

File

vendor/phpspec/prophecy/src/Prophecy/Doubler/NameGenerator.php, line 22

Namespace

Prophecy\Doubler
View source
class NameGenerator {
  private static $counter = 1;

  /**
   * Generates name.
   *
   * @param ReflectionClass   $class
   * @param ReflectionClass[] $interfaces
   *
   * @return string
   */
  public function name(ReflectionClass $class = null, array $interfaces) {
    $parts = array();
    if (null !== $class) {
      $parts[] = $class
        ->getName();
    }
    else {
      foreach ($interfaces as $interface) {
        $parts[] = $interface
          ->getShortName();
      }
    }
    if (!count($parts)) {
      $parts[] = 'stdClass';
    }
    return sprintf('Double\\%s\\P%d', implode('\\', $parts), self::$counter++);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
NameGenerator::$counter private static property
NameGenerator::name public function Generates name.