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

WithGroups   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Test Coverage

Coverage 85.71%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 8
c 1
b 0
f 0
dl 0
loc 20
ccs 6
cts 7
cp 0.8571
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A getGroups() 0 9 3
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
}