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

Function lastSegment

src/resolution/frameworks/drupal.ts:73–78  ·  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

71 * Returns `null` for strings that don't look like a FQCN.
72 */
73function lastSegment(fqcn: string): string | null {
74 const clean = fqcn.replace(/^\\+/, '').trim();
75 if (!clean.includes('\\')) return null;
76 const parts = clean.split('\\');
77 return parts[parts.length - 1] ?? null;
78}
79
80/**
81 * Derive the Drupal module name from a file path.

Callers 1

resolveFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected