SitemapFactory::__invoke()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
dl 0
loc 8
ccs 0
cts 6
cp 0
rs 10
c 1
b 0
f 0
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Application\Handler;
6
7
use Application\Model\News;
8
use Application\Model\Product;
9
use Doctrine\ORM\EntityManager;
10
use Psr\Container\ContainerInterface;
11
12
class SitemapFactory
13
{
14
    public function __invoke(ContainerInterface $container): SitemapHandler
15
    {
16
        $config = $container->get('config');
17
        $entityManager = $container->get(EntityManager::class);
18
        $productRepository = $entityManager->getRepository(Product::class);
19
        $newsRepository = $entityManager->getRepository(News::class);
20
21
        return new SitemapHandler($productRepository, $newsRepository, $config['baseUrl'], $config['sitemapStaticPages']);
22
    }
23
}
24