YouTubeShortCodeHandler   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Test Coverage

Coverage 100%
Metric Value
wmc 6
lcom 0
cbo 3
dl 0
loc 35
ccs 14
cts 14
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B parse_youtube() 0 31 6
1
<?php
2
3
class YouTubeShortCodeHandler {
4
5
	// taken from http://www.ssbits.com/tutorials/2010/2-4-using-short-codes-to-embed-a-youtube-video/ and adapted for SS3
6 7
	public static function parse_youtube($arguments, $caption = null, $parser = null, $tagName) {
7
		// first things first, if we dont have a video ID, then we don't need to
8
		// go any further
9 7
		if (empty($arguments['id'])) {
10 1
			return;
11
		}
12
13 6
		$customise = array();
14
15
		// YouTube video id
16 6
		$customise['YouTubeID'] = $arguments['id'];
17
18
		//play the video on page load
19 6
		$set = isset($arguments['autoplay']);
20 6
		$customise['AutoPlay'] = $set ? true : false;
21
22
		//set the caption
23 6
		$customise['Caption'] = $caption ? Convert::raw2xml($caption) : false;
24
25
		//set dimensions
26 6
		$widthSet = isset($arguments['width']);
27 6
		$heightSet = isset($arguments['height']);
28 6
		$customise['Width'] = $widthSet ? $arguments['width'] : 560;
29 6
		$customise['Height'] = $heightSet ? $arguments['height'] : 315;
30
31
		//get our YouTube template
32 6
		$template = new SSViewer('YouTube');
33
34
		//return the customised template
35 6
		return $template->process(new ArrayData($customise));
36
	}
37
}
38