Completed
Push — master ( f4bdff...fef961 )
by Thomas
01:46
created

UnitCollection   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 28.57%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 29
ccs 2
cts 7
cp 0.2857
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A get() 0 3 1
A findUnitByStart() 0 9 3
1
<?php
2
namespace gossi\formatter\collections;
3
4
use gossi\formatter\entities\Unit;
5
use phootwork\collection\ArrayList;
6
use phootwork\tokenizer\Token;
7
8
class UnitCollection extends ArrayList {
9
10
	/**
11
	 * Retrieves a token at the given index
12
	 * 
13
	 * @param int $index the given index
14
	 * @return Unit
15
	 */
16 3
	public function get($index) {
17 3
		return parent::get($index);
18
	}
19
20
	/**
21
	 * Searches for blocks that start with a given token and returns it or null, if none is found
22
	 * 
23
	 * @param Token $token
24
	 * @return Unit the found block or null
25
	 */
26
	public function findUnitByStart(Token $token) {
27
		foreach ($this->collection as $unit) {
28
			if ($unit->start === $token) {
29
				return $unit;
30
			}
31
		}
32
33
		return null;
34
	}
35
36
}
37