MCPcopy Create free account
hub / github.com/colbymchenry/codegraph / lastSegment

Function lastSegment

src/resolution/frameworks/drupal.ts:62–67  ·  view source on GitHub ↗

* Parse the last PHP namespace segment from a FQCN like `\Drupal\mymodule\Controller\Foo`. * Returns `null` for strings that don't look like a FQCN.

(fqcn: string)

Source from the content-addressed store, hash-verified

60 * Returns `null` for strings that don't look like a FQCN.
61 */
62function lastSegment(fqcn: string): string | null {
63 const clean = fqcn.replace(/^\\+/, '').trim();
64 if (!clean.includes('\\')) return null;
65 const parts = clean.split('\\');
66 return parts[parts.length - 1] ?? null;
67}
68
69/**
70 * Derive the Drupal module name from a file path.

Callers 1

resolveFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected