Completed
Push — master ( d56647...5f1d83 )
by Kirill
11s
created

Storage::add()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 11
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 1
eloc 6
c 1
b 0
f 0
nc 1
nop 1
dl 0
loc 11
rs 9.4285
1
<?php
2
/**
3
 * This file is part of GitterBot package.
4
 *
5
 * @author Serafim <[email protected]>
6
 * @author butschster <[email protected]>
7
 * @date 11.10.2015 8:26
8
 *
9
 * For the full copyright and license information, please view the LICENSE
10
 * file that was distributed with this source code.
11
 */
12
namespace Domains\Subscriber;
13
14
use Illuminate\Contracts\Container\Container;
15
use Domains\Room\RoomInterface;
16
17
/**
18
 * Class Storage
19
 */
20
class Storage
21
{
22
    /**
23
     * @var SubscriberInterface[]
24
     */
25
    protected $subscribers = [];
26
27
    /**
28
     * @var Container
29
     */
30
    protected $container;
31
32
    /**
33
     * @var RoomInterface
34
     */
35
    protected $room;
36
37
    /**
38
     * Storage constructor.
39
     *
40
     * @param Container     $container
41
     * @param RoomInterface $room
42
     */
43
    public function __construct(Container $container, RoomInterface $room)
44
    {
45
        $this->container = $container;
46
        $this->room = $room;
47
    }
48
49
    /**
50
     * @param $class
51
     * @return $this
52
     */
53
    public function add($class)
54
    {
55
        $this->container->bind($class, $class);
56
        $subscriber = $this->container->make($class);
57
58
        $this->subscribers[] = $subscriber;
59
60
        $subscriber->handle($this->room);
61
62
        return $this;
63
    }
64
}