/**
* @throws \InvalidArgumentException when the file cannot be loaded or when the XML cannot be
* parsed because it does not validate against the scheme
*/
public function load(mixed
$file, string
$type = null
): RouteCollection
{ $path =
$this->locator->
locate($file);
$xml =
$this->
loadFile($path);
$collection =
new RouteCollection();
$collection->
addResource(new FileResource($path));
// process routes and imports
foreach ($xml->documentElement->childNodes
as $node) { if (!
$node instanceof \DOMElement
) { continue;
} $this->
parseNode($collection,
$node,
$path,
$file);
} return $collection;
}