AbstractSystem   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 40
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 40
ccs 0
cts 13
cp 0
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A onRegister() 0 5 1
A getChannel() 0 4 1
A getUser() 0 4 1
1
<?php
2
/**
3
 * This file is part of Platform package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 */
8
declare(strict_types=1);
9
10
namespace Karma\Platform\Io;
11
12
use Karma\Platform\Support\IdentityMap;
13
use Karma\Platform\Support\Loggable;
14
use Psr\Log\LoggerInterface;
15
use React\EventLoop\LoopInterface;
16
use Karma\Platform\Support\LoggableInterface;
17
18
/**
19
 * Class AbstractSystem
20
 * @package Karma\Platform\Io
21
 */
22
abstract class AbstractSystem implements SystemInterface, LoggableInterface
23
{
24
    use Loggable;
25
    use IdentityMap;
26
27
    /**
28
     * @var LoopInterface
29
     */
30
    protected $loop;
31
32
    /**
33
     * @param LoopInterface $loop
34
     * @param null|LoggerInterface $logger
35
     */
36
    public function onRegister(LoopInterface $loop, ?LoggerInterface $logger): void
37
    {
38
        $this->loop = $loop;
39
        $this->logger = $logger;
40
    }
41
42
    /**
43
     * @param string $id
44
     * @param \Closure $then
45
     * @return ChannelInterface
46
     */
47
    public function getChannel(string $id, \Closure $then): ChannelInterface
48
    {
49
        return $this->fetch(ChannelInterface::class, $id, $then);
50
    }
51
52
    /**
53
     * @param string $id
54
     * @param \Closure $then
55
     * @return UserInterface
56
     */
57
    public function getUser(string $id, \Closure $then): UserInterface
58
    {
59
        return $this->fetch(UserInterface::class, $id, $then);
60
    }
61
}
62