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

UnitCollection::findUnitByStart()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 0
cts 5
cp 0
rs 9.9666
c 0
b 0
f 0
cc 3
nc 3
nop 1
crap 12
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