Passed
Push — master ( 795926...7012fc )
by Tomáš
11:11
created

WithGroups::getGroups()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3.0261

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 3
eloc 6
c 1
b 0
f 0
nc 3
nop 0
dl 0
loc 9
ccs 6
cts 7
cp 0.8571
crap 3.0261
rs 10
1
<?php
2
3
4
namespace TournamentGenerator\Traits;
5
6
7
use TournamentGenerator\Group;
8
9
/**
10
 * Trait WithGroups
11
 *
12
 * @package TournamentGenerator\Traits
13
 * @author  Tomáš Vojík <[email protected]>
14
 * @since   0.4
15
 */
16
trait WithGroups
17
{
18
19
	/** @var array Group objects */
20
	protected array $groups = [];
21
22
	/**
23
	 * Get all groups in this object
24
	 *
25
	 * @return Group[]
26
	 */
27 1
	public function getGroups() : array {
28 1
		if ($this instanceof \TournamentGenerator\Interfaces\WithRounds) {
29 1
			$groups = [];
30 1
			foreach ($this->getRounds() as $round) {
31 1
				$groups[] = $round->getGroups();
32
			}
33 1
			return array_merge(...$groups);
34
		}
35
		return $this->groups;
36
	}
37
}