Completed
Push — master ( ae8931...2d50a9 )
by Leo
02:38
created

PrintSHBlocks   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 4

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
c 1
b 0
f 0
lcom 1
cbo 4
dl 0
loc 26
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getAllBlocks() 0 6 1
A getMyBlocks() 0 3 1
A getDockedBlocks() 0 12 3
1
<?php
2
class PrintSHBlocks extends Extension {
3
	
4
	public function getAllBlocks() {
5
		$blocks = new ArrayList();
6
		$blocks->merge($this->getMyBlocks());
7
		$blocks->merge($this->getDockedBlocks());
8
		return $blocks;
9
	}
10
		
11
	public function getMyBlocks() {
12
		return $this->owner->SHBlocks()->sort(array('SortOrder' => 'ASC', 'ID' => 'DESC'));
13
	}
14
	
15
	public function getDockedBlocks() {
16
		$blocks = SHBlock::get()->filter('showBlockbyClass', true);
17
		$blocks_map = $blocks->map('ID', 'shownInClass');
18
		foreach ($blocks_map as $blockID => $Classes) {
19
			$Classes = explode(',', $Classes);
20
			if (!in_array($this->owner->ClassName, $Classes)) {
21
				$blocks = $blocks->exclude('ID', $blockID);
22
			}
23
		}
24
		
25
		return $blocks->sort('SortOrder', 'ASC');
26
	}
27
}