ChannelFactory::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
/*
5
 * Copyright (C)
6
 * Nathan Boiron <[email protected]>
7
 * Romain Canon <[email protected]>
8
 *
9
 * This file is part of the TYPO3 NotiZ project.
10
 * It is free software; you can redistribute it and/or modify it
11
 * under the terms of the GNU General Public License, either
12
 * version 3 of the License, or any later version.
13
 *
14
 * For the full copyright and license information, see:
15
 * http://www.gnu.org/licenses/gpl-3.0.html
16
 */
17
18
namespace CuyZ\Notiz\Core\Channel\Service;
19
20
use CuyZ\Notiz\Core\Channel\Channel;
21
use CuyZ\Notiz\Core\Definition\Tree\Notification\Channel\ChannelDefinition;
22
use TYPO3\CMS\Core\SingletonInterface;
23
use TYPO3\CMS\Extbase\Object\ObjectManager;
0 ignored issues
show
Bug introduced by
The type TYPO3\CMS\Extbase\Object\ObjectManager was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
24
25
class ChannelFactory implements SingletonInterface
26
{
27
    /**
28
     * @var ObjectManager
29
     */
30
    protected $objectManager;
31
32
    /**
33
     * @param ObjectManager $objectManager
34
     */
35
    public function __construct(ObjectManager $objectManager)
36
    {
37
        $this->objectManager = $objectManager;
38
    }
39
40
    /**
41
     * @param ChannelDefinition $channelDefinition
42
     * @return Channel
43
     */
44
    public function create(ChannelDefinition $channelDefinition): Channel
45
    {
46
        $settings = clone $channelDefinition->getSettings();
47
48
        /** @var Channel $channel */
49
        $channel = $this->objectManager->get($channelDefinition->getClassName(), $settings);
50
51
        return $channel;
52
    }
53
}
54