Passed
Pull Request — master (#1266)
by Matthew
04:13
created

AggregateScrobbler::recordTrackPlayed()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 2
nc 2
nop 3
dl 0
loc 4
rs 10
c 1
b 0
f 0
1
<?php declare(strict_types=1);
2
3
/**
4
 * ownCloud - Music app
5
 *
6
 * This file is licensed under the Affero General Public License version 3 or
7
 * later. See the COPYING file.
8
 *
9
 * @author Matthew Wells
10
 * @copyright Matthew Wells 2025
11
 */
12
13
namespace OCA\Music\Service;
14
15
use DateTime;
16
17
class AggregateScrobbler implements Scrobbler
18
{
19
	/** @var array<Scrobbler> $scrobblers */
20
	private array $scrobblers;
21
22
	public function __construct(array $scrobblers)
23
	{
24
		$this->scrobblers = $scrobblers;
25
	}
26
27
	public function recordTrackPlayed(int $trackId, string $userId, ?\DateTime $timeOfPlay = null): void
28
	{
29
		foreach ($this->scrobblers as $scrobbler) {
30
			$scrobbler->recordTrackPlayed($trackId, $userId, $timeOfPlay);
31
		}
32
	}
33
}