CategoryServiceFactory::__invoke()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 11
rs 9.9
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Category\Factory\Service;
6
7
use Category\Filter\CategoryFilter;
8
use Category\Mapper\CategoryMapper;
9
use Category\Service\CategoryService;
10
use Interop\Container\ContainerInterface;
11
use UploadHelper\Upload;
12
13
class CategoryServiceFactory
14
{
15
    /**
16
     * Executed when factory is invoked.
17
     *
18
     * @param ContainerInterface $container
19
     *
20
     * @return CategoryService
21
     */
22
    public function __invoke(ContainerInterface $container): CategoryService
23
    {
24
        $config = $container->get('config')['upload'];
25
        $upload = new Upload($config['public_path'], $config['non_public_path']);
26
27
        return new CategoryService(
28
            $container->get(CategoryMapper::class),
29
            $container->get(CategoryFilter::class),
30
            $upload
31
        );
32
    }
33
}
34