StreamableTrait   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 10
c 2
b 0
f 0
dl 0
loc 31
rs 10
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A getItemLinks() 0 24 4
1
<?php
2
3
/**
4
 * Provides functionality for retrieving a set of URLs to a specific media item
5
 *
6
 * @author Sam Stenvall <[email protected]>
7
 * @copyright Copyright &copy; Sam Stenvall 2014-
8
 * @license https://www.gnu.org/licenses/gpl.html The GNU General Public License v3.0
9
 */
10
trait StreamableTrait
11
{
12
	
13
	/**
14
	 * Returns a set of links to the media items
15
	 * @return ItemLink[] the item links
16
	 */
17
	public function getItemLinks()
18
	{
19
		$items = array();
20
21
		// An item may consist of multiple items, a file may consist of multiple 
22
		// links
23
		foreach ($this->getStreamableItems() as $mediaItem)
0 ignored issues
show
Bug introduced by
It seems like getStreamableItems() must be provided by classes using this trait. How about adding it as abstract method to this trait? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

23
		foreach ($this->/** @scrutinizer ignore-call */ getStreamableItems() as $mediaItem)
Loading history...
24
		{
25
			$name = $mediaItem->getDisplayName();
26
27
			// Get the links to the media. We have to omit credentials from the 
28
			// URLs if the user is using Internet Explorer since it won't 
29
			// follow such links
30
			$links = VideoLibrary::getVideoLinks($mediaItem->file, Browser::isInternetExplorer());
31
			$linkCount = count($links);
32
33
			foreach ($links as $k=> $link)
34
			{
35
				$label = $linkCount > 1 ? $name.' (#'.++$k.')' : $name;
36
				$items[] = new ItemLink($label, $link, $mediaItem);
37
			}
38
		}
39
40
		return $items;
41
	}
42
43
}
44