createIdentifier($class, $indexOrName); $snippet = self::$coverage->cache($identifier); if (!$snippet) { $snippet = self::$parser->classExample($class, $indexOrName); } self::$coverage->cover($snippet->identifier()); return clone $snippet; } /** * Retrieve a snippet from a magic method docblock (i.e. `@method` tag * nexted inside a class-level docblock). * * @param string $class The class name * @param string $method The method name * @param string|int $indexOrName The index of the snippet, or its name. * @return Snippet * * @experimental * @internal */ public static function snippetFromMagicMethod($class, $method, $indexOrName = 0) { $name = $class .'::'. $method; $identifier = self::$parser->createIdentifier($name, $indexOrName); $snippet = self::$coverage->cache($identifier); if (!$snippet) { throw new \Exception('Magic Method '. $name .' was not found'); } self::$coverage->cover($identifier); return clone $snippet; } /** * Retrieve a snippet from a method docblock. * * @param string $class The class name * @param string $method The method name * @param string|int $indexOrName The index of the snippet, or its name. * @return Snippet * * @experimental * @internal */ public static function snippetFromMethod($class, $method, $indexOrName = 0) { $name = $class .'::'. $method; $identifier = self::$parser->createIdentifier($name, $indexOrName); $snippet = self::$coverage->cache($identifier); if (!$snippet) { $snippet = self::$parser->methodExample($class, $method, $indexOrName); } self::$coverage->cover($identifier); return clone $snippet; } }