2022-08-28 18:44:30 +00:00
|
|
|
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
|
|
|
|
namespace OCA\GPodderSync\Core\PodcastData;
|
|
|
|
|
2022-09-17 19:47:49 +00:00
|
|
|
use JsonSerializable;
|
|
|
|
|
|
|
|
class PodcastActionCounts implements JsonSerializable {
|
2022-08-28 18:44:30 +00:00
|
|
|
private int $delete = 0;
|
|
|
|
private int $download = 0;
|
|
|
|
private int $flattr = 0;
|
|
|
|
private int $new = 0;
|
|
|
|
private int $play = 0;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param string $action
|
|
|
|
*/
|
|
|
|
public function incrementAction(string $action): void {
|
|
|
|
switch ($action) {
|
|
|
|
case 'delete': $this->delete++; break;
|
|
|
|
case 'download': $this->download++; break;
|
|
|
|
case 'flattr': $this->flattr++; break;
|
|
|
|
case 'new': $this->new++; break;
|
|
|
|
case 'play': $this->play++; break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-09-17 19:47:49 +00:00
|
|
|
/**
|
|
|
|
* @return array<string,int>
|
|
|
|
*/
|
2022-08-28 18:44:30 +00:00
|
|
|
public function toArray(): array {
|
2022-09-17 19:47:49 +00:00
|
|
|
return [
|
2022-08-28 18:44:30 +00:00
|
|
|
'delete' => $this->delete,
|
|
|
|
'download' => $this->download,
|
|
|
|
'flattr' => $this->flattr,
|
|
|
|
'new' => $this->new,
|
|
|
|
'play' => $this->play,
|
|
|
|
];
|
|
|
|
}
|
2022-09-17 19:47:49 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @return array<string,int>
|
|
|
|
*/
|
|
|
|
public function jsonSerialize(): mixed {
|
|
|
|
return $this->toArray();
|
|
|
|
}
|
2022-08-28 18:44:30 +00:00
|
|
|
}
|