Skip to main content
Drupal API
User account menu
  • Log in

Breadcrumb

  1. Drupal Core 11.1.x
  2. NameGenerator.php

class NameGenerator

Name generator. Generates classname for double.

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

Hierarchy

  • class \Prophecy\Doubler\NameGenerator

Expanded class hierarchy of NameGenerator

File

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

Namespace

Prophecy\Doubler
View source
class NameGenerator {
    
    /**
     * @var int
     */
    private static $counter = 1;
    
    /**
     * Generates name.
     *
     * @param ReflectionClass<object>|null $class
     * @param ReflectionClass<object>[]    $interfaces
     *
     * @return string
     */
    public function name(?ReflectionClass $class, 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

Title Sort descending Modifiers Object type Summary
NameGenerator::$counter private static property
NameGenerator::name public function Generates name.
RSS feed
Powered by Drupal