This repository was archived by the owner on Dec 20, 2025. It is now read-only.

Description
Is your feature request related to a problem? Please describe.
reduce need for "boilerplate" functions
Describe the solution you'd like
I found myself implementing static factory functions to easily assemble a SitemapIndex or UrlSet:
SitemapIndex::getInstanceForSitemaps($sitemaps): static
UrlSet::getInstanceForUrls($urls): static
Describe alternatives you've considered
Instead of using static factory functions, we might use dedicated factory classes:
SitemapIndexFactory::getInstance($sitemaps = null): Sitemap
UrlSetFactory::getInstance($urls = null): UrlSet
Additional context
Implementation is quite trivial, I currently have:
class SitemapIndex extends \Thepixeldeveloper\Sitemap\SitemapIndex
{
public static function getInstanceForSitemaps($sitemaps) : self
{
$sitemapIndex = new static();
foreach ($sitemaps as $sitemap) {
$sitemapIndex->addSitemap($sitemap);
}
return $sitemapIndex;
}
}
class UrlSet extends \Thepixeldeveloper\Sitemap\UrlSet
{
/**
* @param OutputInterface[] $urls
*
* @return static
*/
public static function getInstanceForUrls($urls) : self
{
$urlSet = new static();
foreach ($urls as $url) {
$urlSet->addUrl($url);
}
return $urlSet;
}
}
I can provide a PR, would it be considered? Any suggestions / preference?