Completed
Push — master ( 3ee305...36a69b )
by Ryan
07:04
created

GetStream::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
dl 0
loc 5
rs 9.4285
c 1
b 0
f 1
cc 1
eloc 3
nc 1
nop 2
1
<?php namespace Anomaly\Streams\Platform\Stream\Command;
2
3
use Anomaly\Streams\Platform\Entry\Contract\EntryInterface;
4
use Illuminate\Contracts\Bus\SelfHandling;
5
use Illuminate\Contracts\Container\Container;
6
7
/**
8
 * Class GetStream
9
 *
10
 * @link          http://pyrocms.com/
11
 * @author        PyroCMS, Inc. <[email protected]>
12
 * @author        Ryan Thompson <[email protected]>
13
 * @package       Anomaly\Streams\Platform\Stream\Command
14
 */
15
class GetStream implements SelfHandling
16
{
17
18
    /**
19
     * The stream slug.
20
     *
21
     * @var string
22
     */
23
    protected $slug;
24
25
    /**
26
     * The stream namespace.
27
     *
28
     * @var string
29
     */
30
    protected $namespace;
31
32
    /**
33
     * Create a new GetStream instance.
34
     *
35
     * @param string $namespace
36
     * @param string $slug
37
     */
38
    public function __construct($namespace, $slug)
39
    {
40
        $this->slug      = $slug;
41
        $this->namespace = $namespace;
42
    }
43
44
    /**
45
     * Handle the command.
46
     *
47
     * @param Container $container
48
     * @return \Anomaly\Streams\Platform\Stream\Contract\StreamInterface|null
49
     */
50
    public function handle(Container $container)
51
    {
52
        /* @var EntryInterface $model */
53
        $model = $container->make(
54
            "Anomaly\\Streams\\Platform\\Model\\{$this->namespace}\\{$this->namespace}{$this->slug}EntryModel"
55
        );
56
57
        return $model->getStream();
58
    }
59
}
60