SchemaParser
in package
Class SchemaParser
A utility for extracting and collecting linkbases by scanning an entry schema file and recursively processing its dependencies through schema imports and includes. The parser supports detection and categorization of linkbases used within XBRL schema files.
Table of Contents
Properties
- $collectedLinkbases : array<string|int, mixed>
- $visitedSchemas : array<string|int, mixed>
Methods
- extractLinkbases() : array<string|int, mixed>
- Extracts and collects linkbases by scanning an entry schema file and its dependencies.
- buildPath() : string
- Constructs an absolute file path by combining a base directory and a relative path or URL.
- detectType() : string|null
- Detects the type of a linkbase based on its href or role.
- isUrl() : bool
- scanSchema() : void
Properties
$collectedLinkbases
private
array<string|int, mixed>
$collectedLinkbases
= []
$visitedSchemas
private
array<string|int, mixed>
$visitedSchemas
= []
Methods
extractLinkbases()
Extracts and collects linkbases by scanning an entry schema file and its dependencies.
public
extractLinkbases(string $entryFile) : array<string|int, mixed>
Parameters
- $entryFile : string
-
The path to the entry schema file to be scanned.
Return values
array<string|int, mixed> —An array of collected linkbases.
buildPath()
Constructs an absolute file path by combining a base directory and a relative path or URL.
private
buildPath(string $baseDir, string $href) : string
Parameters
- $baseDir : string
-
The base directory to be used for constructing the path.
- $href : string
-
The relative path or URL to be resolved.
Return values
string —The constructed absolute path or the original URL if $href is a valid URL.
detectType()
Detects the type of a linkbase based on its href or role.
private
detectType(string $href, string $role) : string|null
Parameters
- $href : string
-
The href value to analyze.
- $role : string
-
The role value to analyze.
Return values
string|null —The detected type of the linkbase ('presentation', 'definition', 'label', or 'formula'), or null if no type is detected.
isUrl()
private
isUrl(string $path) : bool
Parameters
- $path : string
Return values
boolscanSchema()
private
scanSchema(string $file) : void
Parameters
- $file : string