scratch – Blame information for rev 115

Subversion Repositories:
Rev:
Rev Author Line No. Line
115 office 1 <?php
2  
3 /*
4 * This file is part of PHP-FFmpeg.
5 *
6 * (c) Alchemy <info@alchemy.fr>
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 FFMpeg\FFProbe;
13  
14 use FFMpeg\FFProbe;
15 use FFMpeg\FFProbe\DataMapping\Format;
16 use FFMpeg\FFProbe\DataMapping\StreamCollection;
17 use FFMpeg\FFProbe\DataMapping\Stream;
18 use FFMpeg\Exception\InvalidArgumentException;
19  
20 class Mapper implements MapperInterface
21 {
22 /**
23 * {@inheritdoc}
24 */
25 public function map($type, $data)
26 {
27 switch ($type) {
28 case FFProbe::TYPE_FORMAT:
29 return $this->mapFormat($data);
30 case FFProbe::TYPE_STREAMS:
31 return $this->mapStreams($data);
32 default:
33 throw new InvalidArgumentException(sprintf(
34 'Invalid type `%s`.', $type
35 ));
36 }
37 }
38  
39 private function mapFormat($data)
40 {
41 return new Format($data['format']);
42 }
43  
44 private function mapStreams($data)
45 {
46 $streams = new StreamCollection();
47  
48 foreach ($data['streams'] as $properties) {
49 $streams->add(new Stream($properties));
50 }
51  
52 return $streams;
53 }
54 }