1 | <?php |
||
15 | class MediaInfoContainer implements \JsonSerializable |
||
16 | { |
||
17 | use DumpTrait; |
||
18 | |||
19 | const GENERAL_CLASS = 'Mhor\MediaInfo\Type\General'; |
||
20 | const AUDIO_CLASS = 'Mhor\MediaInfo\Type\Audio'; |
||
21 | const IMAGE_CLASS = 'Mhor\MediaInfo\Type\Image'; |
||
22 | const VIDEO_CLASS = 'Mhor\MediaInfo\Type\Video'; |
||
23 | const SUBTITLE_CLASS = 'Mhor\MediaInfo\Type\Subtitle'; |
||
24 | const MENU_CLASS = 'Mhor\MediaInfo\Type\Menu'; |
||
25 | const OTHER_CLASS = 'Mhor\MediaInfo\Type\Other'; |
||
26 | |||
27 | /** |
||
28 | * @var string |
||
29 | */ |
||
30 | private $version; |
||
31 | |||
32 | /** |
||
33 | * @var General |
||
34 | */ |
||
35 | private $general; |
||
36 | |||
37 | /** |
||
38 | * @var Audio[] |
||
39 | */ |
||
40 | private $audios = []; |
||
41 | |||
42 | /** |
||
43 | * @var Video[] |
||
44 | */ |
||
45 | private $videos = []; |
||
46 | |||
47 | /** |
||
48 | * @var Subtitle[] |
||
49 | */ |
||
50 | private $subtitles = []; |
||
51 | |||
52 | /** |
||
53 | * @var Image[] |
||
54 | */ |
||
55 | private $images = []; |
||
56 | |||
57 | /** |
||
58 | * @var Menu[] |
||
59 | */ |
||
60 | private $menus = []; |
||
61 | |||
62 | /** |
||
63 | * @var Other[] |
||
64 | */ |
||
65 | private $others = []; |
||
66 | |||
67 | /** |
||
68 | * @return General|null |
||
69 | */ |
||
70 | 5 | public function getGeneral(): ?General |
|
74 | |||
75 | /** |
||
76 | * @return Audio[] |
||
77 | */ |
||
78 | 5 | public function getAudios(): array |
|
82 | |||
83 | /** |
||
84 | * @return Image[] |
||
85 | */ |
||
86 | 2 | public function getImages(): array |
|
90 | |||
91 | /** |
||
92 | * @return Menu[] |
||
93 | */ |
||
94 | 1 | public function getMenus(): array |
|
98 | |||
99 | /** |
||
100 | * @return Other[] |
||
101 | */ |
||
102 | 1 | public function getOthers(): array |
|
106 | |||
107 | /** |
||
108 | * @param string $version |
||
109 | */ |
||
110 | 5 | public function setVersion($version): void |
|
114 | |||
115 | /** |
||
116 | * @return string|null |
||
117 | */ |
||
118 | 1 | public function getVersion(): ?string |
|
122 | |||
123 | /** |
||
124 | * @return Video[] |
||
125 | */ |
||
126 | 2 | public function getVideos(): array |
|
130 | |||
131 | /** |
||
132 | * @return Subtitle[] |
||
133 | */ |
||
134 | 2 | public function getSubtitles(): array |
|
138 | |||
139 | /** |
||
140 | * @param General $general |
||
141 | */ |
||
142 | 10 | public function setGeneral($general): void |
|
146 | |||
147 | /** |
||
148 | * @param AbstractType $trackType |
||
149 | * |
||
150 | * @throws \Exception |
||
151 | */ |
||
152 | 14 | public function add(AbstractType $trackType): void |
|
153 | { |
||
154 | 14 | switch (get_class($trackType)) { |
|
155 | 14 | case self::AUDIO_CLASS: |
|
156 | 13 | $this->addAudio($trackType); |
|
157 | 13 | break; |
|
158 | 11 | case self::VIDEO_CLASS: |
|
159 | 1 | $this->addVideo($trackType); |
|
160 | 1 | break; |
|
161 | 11 | case self::IMAGE_CLASS: |
|
162 | 1 | $this->addImage($trackType); |
|
163 | 1 | break; |
|
164 | 11 | case self::GENERAL_CLASS: |
|
165 | 10 | $this->setGeneral($trackType); |
|
166 | 10 | break; |
|
167 | 5 | case self::SUBTITLE_CLASS: |
|
168 | 4 | $this->addSubtitle($trackType); |
|
169 | 4 | break; |
|
170 | 3 | case self::MENU_CLASS: |
|
171 | 1 | $this->addMenu($trackType); |
|
172 | 1 | break; |
|
173 | 2 | case self::OTHER_CLASS: |
|
174 | 1 | $this->addOther($trackType); |
|
175 | 1 | break; |
|
176 | default: |
||
177 | 1 | throw new \Exception('Unknown type'); |
|
178 | } |
||
179 | 13 | } |
|
180 | |||
181 | /** |
||
182 | * @param Audio $audio |
||
183 | */ |
||
184 | 13 | private function addAudio(Audio $audio): void |
|
188 | |||
189 | /** |
||
190 | * @param Video $video |
||
191 | */ |
||
192 | 1 | private function addVideo(Video $video): void |
|
196 | |||
197 | /** |
||
198 | * @param Image $image |
||
199 | */ |
||
200 | 1 | private function addImage(Image $image): void |
|
204 | |||
205 | /** |
||
206 | * @param Subtitle $subtitle |
||
207 | */ |
||
208 | 4 | private function addSubtitle(Subtitle $subtitle): void |
|
212 | |||
213 | /** |
||
214 | * @param Menu $menu |
||
215 | */ |
||
216 | 1 | private function addMenu(Menu $menu): void |
|
220 | |||
221 | /** |
||
222 | * @param Other $other |
||
223 | */ |
||
224 | 1 | private function addOther(Other $other): void |
|
228 | } |
||
229 |