| Total Complexity | 12 |
| Total Lines | 82 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 1 | Features | 0 |
| 1 | <?php |
||
| 16 | class StreamCollection implements \Countable, \IteratorAggregate |
||
| 17 | { |
||
| 18 | private $streams; |
||
| 19 | |||
| 20 | /** |
||
| 21 | * @param array $streams |
||
| 22 | */ |
||
| 23 | public function __construct(array $streams) |
||
| 24 | { |
||
| 25 | $this->streams = $streams; |
||
| 26 | } |
||
| 27 | |||
| 28 | /** |
||
| 29 | * @return array |
||
| 30 | */ |
||
| 31 | public function all() |
||
| 32 | { |
||
| 33 | return $this->streams; |
||
| 34 | } |
||
| 35 | |||
| 36 | /** |
||
| 37 | * @return StreamCollection |
||
| 38 | */ |
||
| 39 | public function audios() |
||
| 40 | { |
||
| 41 | $audios = array_filter($this->streams, function (Stream $stream) { |
||
| 42 | return $stream->isAudio(); |
||
| 43 | }); |
||
| 44 | |||
| 45 | return new static(array_values($audios)); |
||
| 46 | } |
||
| 47 | |||
| 48 | /** |
||
| 49 | * @return StreamCollection |
||
| 50 | */ |
||
| 51 | public function videos() |
||
| 58 | } |
||
| 59 | |||
| 60 | /** |
||
| 61 | * @return mixed|null |
||
| 62 | */ |
||
| 63 | public function general() |
||
| 64 | { |
||
| 65 | foreach ($this->streams as $stream){ |
||
| 66 | if ($stream instanceof Stream && $stream->get('@type') === "General"){ |
||
|
|
|||
| 67 | return $stream; |
||
| 68 | } |
||
| 69 | } |
||
| 70 | |||
| 71 | return null; |
||
| 72 | } |
||
| 73 | |||
| 74 | /** |
||
| 75 | * @return null | Stream |
||
| 76 | */ |
||
| 77 | public function first() |
||
| 82 | } |
||
| 83 | |||
| 84 | /** |
||
| 85 | * @return int |
||
| 86 | */ |
||
| 87 | public function count() |
||
| 88 | { |
||
| 89 | return count($this->streams); |
||
| 90 | } |
||
| 91 | |||
| 92 | /** |
||
| 93 | * {@inheritdoc} |
||
| 94 | */ |
||
| 95 | public function getIterator() |
||
| 98 | } |
||
| 99 | } |
||
| 100 |