Factory   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 47
Duplicated Lines 0 %

Test Coverage

Coverage 86.67%

Importance

Changes 0
Metric Value
eloc 14
dl 0
loc 47
ccs 13
cts 15
cp 0.8667
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A injectConfigurationProvider() 0 6 2
A createServer() 0 9 1
A injectObjectManager() 0 3 1
1
<?php
2
namespace Aoe\Asdis\Domain\Model\Server;
3
4
use Aoe\Asdis\Domain\Model\Server;
5
use Aoe\Asdis\System\Configuration\Provider;
6
use TYPO3\CMS\Extbase\Object\ObjectManagerInterface;
7
8
/**
9
 * Factory for server objects.
10
 */
11
class Factory
12
{
13
    /**
14
     * @var \TYPO3\CMS\Extbase\Object\ObjectManagerInterface
15
     */
16
    private $objectManager;
17
18
    /**
19
     * @var string
20
     */
21
    private $protocolMarker;
22
23
    /**
24
     * @param \TYPO3\CMS\Extbase\Object\ObjectManagerInterface $objectManager
25
     */
26 1
    public function injectObjectManager(ObjectManagerInterface $objectManager)
27
    {
28 1
        $this->objectManager = $objectManager;
29 1
    }
30
31
    /**
32
     * @param \Aoe\Asdis\System\Configuration\Provider $configurationProvider
33
     */
34 1
    public function injectConfigurationProvider(Provider $configurationProvider)
35
    {
36
        try {
37 1
            $this->protocolMarker = $configurationProvider->getServerProtocolMarker();
38
        } catch(\Exception $e) {
39
            $this->protocolMarker = '';
40
        }
41 1
    }
42
43
    /**
44
     * @param string $identifier
45
     * @param string $domain
46
     * @param string $protocol
47
     * @return \Aoe\Asdis\Domain\Model\Server
48
     */
49 1
    public function createServer($identifier, $domain, $protocol)
50
    {
51
        /** @var \Aoe\Asdis\Domain\Model\Server $server */
52 1
        $server = $this->objectManager->get(Server::class);
0 ignored issues
show
Deprecated Code introduced by
The function TYPO3\CMS\Extbase\Object...ManagerInterface::get() has been deprecated: since TYPO3 10.4, will be removed in version 12.0 ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-deprecated  annotation

52
        $server = /** @scrutinizer ignore-deprecated */ $this->objectManager->get(Server::class);

This function has been deprecated. The supplier of the function has supplied an explanatory message.

The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.

Loading history...
53 1
        $server->setIdentifier($identifier);
54 1
        $server->setDomain($domain);
55 1
        $server->setProtocol($protocol);
56 1
        $server->setProtocolMarker($this->protocolMarker);
57 1
        return $server;
58
    }
59
}