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

VideoEncodedEvent::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 2
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
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
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
/**
58
 * @internal
59
 */
60
trait VideoEncodedEventTrait
61
{
62
    /**
63
     * The id of the encoded video
64
     * @var string
65
     */
66
    private $videoId;
67
68
    /**
69
     * List of encoding ids of this video
70
     * @var string[]
71
     */
72
    private $encodingIds = array();
73
74
    /**
75
     * Constructs a new VideoEncodedEvent.
76
     *
77
     * @param string   $videoId     Video id
78
     * @param string[] $encodingIds Ids of the video's encodings
79
     */
80 4
    public function __construct($videoId, array $encodingIds)
81
    {
82 4
        $this->videoId = $videoId;
83 4
        $this->encodingIds = $encodingIds;
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 video's encoding ids.
98
     *
99
     * @return string[] The encoding ids
100
     */
101 3
    public function getEncodingIds()
102
    {
103 3
        return $this->encodingIds;
104
    }
105
}
106