Completed
Push — symfony-5 ( 5166f9...32830f )
by Christian
03:21
created

EncodingProgressEvent::getEncodingId()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 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 since 1.5
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 since 1.5
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
trait EncodingProgressEventTrait
58
{
59
    /**
60
     * The id of the encoded video
61
     * @var string
62
     */
63
    private $videoId;
64
65
    /**
66
     * The id of the encoding
67
     * @var string
68
     */
69
    private $encodingId;
70
71
    /**
72
     * The encoding progress
73
     * @var int
74
     */
75
    private $progress;
76
77
    /**
78
     * Constructs a new EncodingProgressEvent.
79
     *
80
     * @param string $videoId    Video id
81
     * @param string $encodingId Encoding id
82
     * @param int    $progress   Progress of the encoding
83
     */
84 4
    public function __construct($videoId, $encodingId, $progress)
85
    {
86 4
        $this->videoId = $videoId;
87 4
        $this->encodingId = $encodingId;
88 4
        $this->progress = $progress;
89 4
    }
90
91
    /**
92
     * Returns the video id.
93
     *
94
     * @return string The video id
95
     */
96 3
    public function getVideoId()
97
    {
98 3
        return $this->videoId;
99
    }
100
101
    /**
102
     * Returns the encoding id.
103
     *
104
     * @return string The encoding id
105
     */
106 3
    public function getEncodingId()
107
    {
108 3
        return $this->encodingId;
109
    }
110
111
    /**
112
     * Returns the encoding progress.
113
     *
114
     * @return int The progress
115
     */
116 3
    public function getProgress()
117
    {
118 3
        return $this->progress;
119
    }
120
}
121