for testing and deploying your application
for finding and fixing issues
for empowering human code reviews
<?php
namespace JeroenDesloovere\SitemapBundle\Provider;
use JeroenDesloovere\SitemapBundle\Item\ChangeFrequency;
use JeroenDesloovere\SitemapBundle\Item\SitemapItem;
use JeroenDesloovere\SitemapBundle\Item\SitemapItems;
class SitemapProvider
{
/** @var SitemapItems */
private $items;
/** @var string - bvb: NewsArticle, will create a "sitemap_NewsArticle.xml" file */
private $key;
public function __construct(string $key)
$this->key = $key;
$this->items = new SitemapItems();
}
public function getItems(): SitemapItems
return $this->items;
public function getFilename(): string
try {
$suffix = (new \ReflectionClass($this->getKey()))->getShortName();
} catch (\Exception $e) {
$suffix = array_pop(explode('\\', $this->getKey()));
explode('\', $this->getKey())
array_pop()
$array
If this is a false-positive, you can also ignore this issue in your code via the ignore-type annotation
ignore-type
$suffix = array_pop(/** @scrutinizer ignore-type */ explode('\\', $this->getKey()));
return 'sitemap_' . $suffix;
public function getKey(): string
return $this->key;
public function createItem(
string $url,
\DateTime $lastModifiedOn,
ChangeFrequency $changeFrequency,
int $priority = 5
): void {
$this->items->add(new SitemapItem($url, $lastModifiedOn, $changeFrequency, $priority));