UnitCollection::get()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 3
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
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 2
	public function findUnitByStart(Token $token) {
27 2
		foreach ($this->collection as $unit) {
28 1
			if ($unit->start === $token) {
29 1
				return $unit;
30
			}
31
		}
32
33 2
		return null;
34
	}
35
36
}
37