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

AggregateScrobbler   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 5
dl 0
loc 14
rs 10
c 1
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A recordTrackPlayed() 0 4 2
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
}