Completed
Push — master ( a7b3c5...a3697f )
by Christian
04:52 queued 11s
created

EncodingCompleteEventTrait   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 46
Duplicated Lines 0 %

Coupling/Cohesion

Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 3
cbo 0
dl 0
loc 46
ccs 8
cts 8
cp 1
c 0
b 0
f 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 5 1
A getVideoId() 0 4 1
A getEncodingId() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of the XabbuhPandaBundle package.
5
 *
6
 * (c) Christian Flothmann <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Xabbuh\PandaBundle\Event;
13
14
use Symfony\Component\EventDispatcher\Event as LegacyEvent;
15
use Symfony\Contracts\EventDispatcher\Event;
16
17 1
if (class_exists(LegacyEvent::class)) {
18
    /**
19
     * Event that is triggered when an encoding has successfully finished.
20
     *
21
     * @author Christian Flothmann <[email protected]>
22
     *
23
     * @final
24
     */
25
    class EncodingCompleteEvent extends LegacyEvent
26
    {
27
        use EncodingCompleteEventTrait;
28
29
        /**
30
         * The ENCODING_COMPLETE event occurs when an encoding is done or failed.
31
         *
32
         * The event listener method receives a Xabbuh\PandaBundle\Event\EncodingCompleteEvent instance.
33
         */
34
        const NAME = 'xabbuh_panda.encoding_complete';
35
    }
36
} else {
37
    /**
38
     * Event that is triggered when an encoding has successfully finished.
39
     *
40
     * @author Christian Flothmann <[email protected]>
41
     *
42
     * @final
43
     */
44
    class EncodingCompleteEvent extends Event
0 ignored issues
show
Comprehensibility Best Practice introduced by
The type Xabbuh\PandaBundle\Event\EncodingCompleteEvent has been defined more than once; this definition is ignored, only the first definition in this file (L25-35) is considered.

This check looks for classes that have been defined more than once in the same file.

If you can, we would recommend to use standard object-oriented programming techniques. For example, to avoid multiple types, it might make sense to create a common interface, and then multiple, different implementations for that interface.

This also has the side-effect of providing you with better IDE auto-completion, static analysis and also better OPCode caching from PHP.

Loading history...
45
    {
46
        use EncodingCompleteEventTrait;
47
48
        /**
49
         * The ENCODING_COMPLETE event occurs when an encoding is done or failed.
50
         *
51
         * The event listener method receives a Xabbuh\PandaBundle\Event\EncodingCompleteEvent instance.
52
         */
53
        const NAME = 'xabbuh_panda.encoding_complete';
54
    }
55
}
56
57
/**
58
 * @internal
59
 */
60
trait EncodingCompleteEventTrait
61
{
62
    /**
63
     * The id of the encoded video
64
     * @var string
65
     */
66
    private $videoId;
67
68
    /**
69
     * The id of the encoding
70
     * @var string
71
     */
72
    private $encodingId;
73
74
    /**
75
     * Constructs a new EncodingCompleteEvent.
76
     *
77
     * @param string $videoId    Video id
78
     * @param string $encodingId Encoding id
79
     */
80 4
    public function __construct($videoId, $encodingId)
81
    {
82 4
        $this->videoId = $videoId;
83 4
        $this->encodingId = $encodingId;
84 4
    }
85
86
    /**
87
     * Returns the video id.
88
     *
89
     * @return string The video id
90
     */
91 3
    public function getVideoId()
92
    {
93 3
        return $this->videoId;
94
    }
95
96
    /**
97
     * Returns the encoding id.
98
     *
99
     * @return string The encoding id
100
     */
101 3
    public function getEncodingId()
102
    {
103 3
        return $this->encodingId;
104
    }
105
}
106