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

EncodingProgressEventTrait   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 64
Duplicated Lines 0 %

Coupling/Cohesion

Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 4
cbo 0
dl 0
loc 64
ccs 11
cts 11
cp 1
c 0
b 0
f 0
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getVideoId() 0 4 1
A getEncodingId() 0 4 1
A getProgress() 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 repeatedly while an encoding process is running.
20
     *
21
     * @author Christian Flothmann <[email protected]>
22
     *
23
     * @final
24
     */
25
    class EncodingProgressEvent extends LegacyEvent
26
    {
27
        use EncodingProgressEventTrait;
28
29
        /**
30
         * The ENCODING_PROGRESS event occurs repeatedly while an encoding process is running.
31
         *
32
         * The event listener method receives a Xabbuh\PandaBundle\Event\EncodingProgressEvent instance.
33
         */
34
        const NAME = 'xabbuh_panda.encoding_progress';
35
    }
36
} else {
37
    /**
38
     * Event that is triggered repeatedly while an encoding process is running.
39
     *
40
     * @author Christian Flothmann <[email protected]>
41
     *
42
     * @final
43
     */
44
    class EncodingProgressEvent extends Event
0 ignored issues
show
Comprehensibility Best Practice introduced by
The type Xabbuh\PandaBundle\Event\EncodingProgressEvent 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 EncodingProgressEventTrait;
47
48
        /**
49
         * The ENCODING_PROGRESS event occurs repeatedly while an encoding process is running.
50
         *
51
         * The event listener method receives a Xabbuh\PandaBundle\Event\EncodingProgressEvent instance.
52
         */
53
        const NAME = 'xabbuh_panda.encoding_progress';
54
    }
55
}
56
57
/**
58
 * @internal
59
 */
60
trait EncodingProgressEventTrait
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
     * The encoding progress
76
     * @var int
77
     */
78
    private $progress;
79
80
    /**
81
     * Constructs a new EncodingProgressEvent.
82
     *
83
     * @param string $videoId    Video id
84
     * @param string $encodingId Encoding id
85
     * @param int    $progress   Progress of the encoding
86
     */
87 4
    public function __construct($videoId, $encodingId, $progress)
88
    {
89 4
        $this->videoId = $videoId;
90 4
        $this->encodingId = $encodingId;
91 4
        $this->progress = $progress;
92 4
    }
93
94
    /**
95
     * Returns the video id.
96
     *
97
     * @return string The video id
98
     */
99 3
    public function getVideoId()
100
    {
101 3
        return $this->videoId;
102
    }
103
104
    /**
105
     * Returns the encoding id.
106
     *
107
     * @return string The encoding id
108
     */
109 3
    public function getEncodingId()
110
    {
111 3
        return $this->encodingId;
112
    }
113
114
    /**
115
     * Returns the encoding progress.
116
     *
117
     * @return int The progress
118
     */
119 3
    public function getProgress()
120
    {
121 3
        return $this->progress;
122
    }
123
}
124