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

WithGames   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A getGames() 0 9 3
1
<?php
2
3
4
namespace TournamentGenerator\Traits;
5
6
7
use TournamentGenerator\Game;
8
9
/**
10
 * Trait WithGames
11
 *
12
 * @package TournamentGenerator\Traits
13
 * @author  Tomáš Vojík <[email protected]>
14
 * @since   0.4
15
 */
16
trait WithGames
17
{
18
	/** @var Game[] List of games */
19
	protected array $games = [];
20
21
	/**
22
	 * Get all tournament games
23
	 *
24
	 * @return Game[]
25
	 */
26 46
	public function getGames() : array {
27 46
		if ($this instanceof \TournamentGenerator\Interfaces\WithRounds) {
28 14
			$games = [];
29 14
			foreach ($this->getRounds() as $round) {
30 14
				$games[] = $round->getGames();
31
			}
32 14
			return array_merge(...$games);
33
		}
34 46
		return $this->games;
35
	}
36
}