Completed
Pull Request — 1.x (#56)
by Christian
04:42 queued 03:39
created

VideoEncodedEvent::getVideoId()   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 when a video was successfully encoded.
20
     *
21
     * @author Christian Flothmann <[email protected]>
22
     *
23
     * @final since 1.5
24
     */
25
    class VideoEncodedEvent extends LegacyEvent
26
    {
27
        use VideoEncodedEventTrait;
28
29
        /**
30
         * The VIDEO_ENCODED event occurs when a video was successfully encoded.
31
         *
32
         * The event listener method receives a Xabbuh\PandaBundle\Event\VideoCreatedEvent instance.
33
         */
34
        const NAME = 'xabbuh_panda.video_encoded';
35
    }
36
} else {
37
    /**
38
     * Event that is triggered when a video was successfully encoded.
39
     *
40
     * @author Christian Flothmann <[email protected]>
41
     *
42
     * @final since 1.5
43
     */
44
    class VideoEncodedEvent extends Event
0 ignored issues
show
Comprehensibility Best Practice introduced by
The type Xabbuh\PandaBundle\Event\VideoEncodedEvent 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 VideoEncodedEventTrait;
47
48
        /**
49
         * The VIDEO_ENCODED event occurs when a video was successfully encoded.
50
         *
51
         * The event listener method receives a Xabbuh\PandaBundle\Event\VideoCreatedEvent instance.
52
         */
53
        const NAME = 'xabbuh_panda.video_encoded';
54
    }
55
}
56
57
trait VideoEncodedEventTrait
58
{
59
    /**
60
     * The id of the encoded video
61
     * @var string
62
     */
63
    private $videoId;
64
65
    /**
66
     * List of encoding ids of this video
67
     * @var string[]
68
     */
69
    private $encodingIds = array();
70
71
    /**
72
     * Constructs a new VideoEncodedEvent.
73
     *
74
     * @param string   $videoId     Video id
75
     * @param string[] $encodingIds Ids of the video's encodings
76
     */
77 4
    public function __construct($videoId, array $encodingIds)
78
    {
79 4
        $this->videoId = $videoId;
80 4
        $this->encodingIds = $encodingIds;
81 4
    }
82
83
    /**
84
     * Returns the video id.
85
     *
86
     * @return string The video id
87
     */
88 3
    public function getVideoId()
89
    {
90 3
        return $this->videoId;
91
    }
92
93
    /**
94
     * Returns the video's encoding ids.
95
     *
96
     * @return string[] The encoding ids
97
     */
98 3
    public function getEncodingIds()
99
    {
100 3
        return $this->encodingIds;
101
    }
102
}
103