Total Complexity | 6 |
Total Lines | 55 |
Duplicated Lines | 0 % |
Changes | 2 | ||
Bugs | 2 | Features | 0 |
1 | <?php |
||
19 | trait Representations |
||
20 | { |
||
21 | /** @var RepsCollection */ |
||
22 | protected $reps; |
||
23 | |||
24 | /** |
||
25 | * add a representation |
||
26 | * @param RepresentationInterface $rep |
||
27 | * @return $this |
||
28 | */ |
||
29 | public function addRepresentation(RepresentationInterface $rep) |
||
30 | { |
||
31 | $this->reps->add($rep); |
||
32 | return $this; |
||
33 | } |
||
34 | |||
35 | /** |
||
36 | * add representations using an array |
||
37 | * @param array $reps |
||
38 | * @return $this |
||
39 | */ |
||
40 | public function addRepresentations(array $reps) |
||
41 | { |
||
42 | array_walk($reps, [$this, 'addRepresentation']); |
||
43 | return $this; |
||
44 | } |
||
45 | |||
46 | /** |
||
47 | * @param array|null $sides |
||
48 | * @param array|null $k_bitrate |
||
49 | * @param string $sort |
||
50 | * @return $this |
||
51 | */ |
||
52 | public function autoGenerateRepresentations(array $sides = null, array $k_bitrate = null, string $sort = "asc") |
||
53 | { |
||
54 | if (!$this->format) { |
||
55 | throw new InvalidArgumentException('First you must set the format of the video'); |
||
56 | } |
||
57 | |||
58 | $reps = new AutoReps($this->getMedia(), $this->getFormat(), $sides, $k_bitrate); |
||
59 | $reps->sort($sort); |
||
60 | |||
61 | foreach ($reps as $rep) { |
||
62 | $this->addRepresentation($rep); |
||
63 | } |
||
64 | |||
65 | return $this; |
||
66 | } |
||
67 | |||
68 | /** |
||
69 | * @return RepsCollection |
||
70 | */ |
||
71 | public function getRepresentations(): RepsCollection |
||
74 | } |
||
75 | } |