Minor entity class refactor.

This commit is contained in:
Buster "Silver Eagle" Neece 2020-03-29 02:16:41 -05:00
parent 22ba84c1ed
commit 94e66f894b
No known key found for this signature in database
GPG Key ID: 6D9E12FF03411F4E
27 changed files with 154 additions and 1367 deletions

View File

@ -73,14 +73,6 @@ class Analytics
*/
protected $station;
/*
* @param Station|null $station
* @param string $type
* @param null $timestamp
* @param int $number_min
* @param int $number_max
* @param int $number_avg
*/
public function __construct(
Station $station = null,
$type = 'day',
@ -97,58 +89,37 @@ class Analytics
$this->number_avg = $number_avg;
}
/**
* @return int|null
*/
public function getId()
public function getId(): ?int
{
return $this->id;
}
/**
* @return string
*/
public function getType(): string
{
return $this->type;
}
/**
* @return int
*/
public function getTimestamp(): int
{
return $this->timestamp;
}
/**
* @return int
*/
public function getNumberMin(): int
{
return $this->number_min;
}
/**
* @return int
*/
public function getNumberMax(): int
{
return $this->number_max;
}
/**
* @return int
*/
public function getNumberAvg(): int
{
return $this->number_avg;
}
/**
* @return Station|null
*/
public function getStation()
public function getStation(): ?Station
{
return $this->station;
}

View File

@ -103,9 +103,6 @@ class ApiKey implements JsonSerializable
return [$identifier, $verifier];
}
/**
* @return string
*/
public function getId(): string
{
return $this->id;
@ -123,9 +120,6 @@ class ApiKey implements JsonSerializable
return hash_equals($this->verifier, $this->hashVerifier($verifier));
}
/**
* @return User
*/
public function getUser(): User
{
return $this->user;
@ -133,7 +127,6 @@ class ApiKey implements JsonSerializable
/**
* @AuditLog\AuditIdentifier
*
* @return string
*/
public function getComment(): ?string
@ -141,12 +134,9 @@ class ApiKey implements JsonSerializable
return $this->comment;
}
/**
* @param string $comment
*/
public function setComment(?string $comment): void
{
$this->comment = $this->_truncateString($comment);
$this->comment = $this->truncateString($comment);
}
public function jsonSerialize()

View File

@ -75,14 +75,6 @@ class AuditLog
*/
protected $user;
/**
* @param int $operation
* @param string $class
* @param string $identifier
* @param string|null $targetClass
* @param string|null $target
* @param array $changes
*/
public function __construct(
int $operation,
string $class,
@ -95,9 +87,9 @@ class AuditLog
$this->user = self::$currentUser;
$this->operation = $operation;
$this->class = $this->_filterClassName($class);
$this->class = $this->filterClassName($class);
$this->identifier = $identifier;
$this->targetClass = $this->_filterClassName($targetClass);
$this->targetClass = $this->filterClassName($targetClass);
$this->target = $target;
$this->changes = $changes;
}
@ -107,7 +99,7 @@ class AuditLog
*
* @return string|null The non-namespaced class name
*/
protected function _filterClassName(?string $class): ?string
protected function filterClassName(?string $class): ?string
{
if (empty($class)) {
return null;
@ -129,73 +121,46 @@ class AuditLog
: null;
}
/**
* @return int
*/
public function getId(): int
{
return $this->id;
}
/**
* @return int
*/
public function getTimestamp(): int
{
return $this->timestamp;
}
/**
* @return int
*/
public function getOperation(): int
{
return $this->operation;
}
/**
* @return string
*/
public function getClass(): string
{
return $this->class;
}
/**
* @return string
*/
public function getIdentifier(): string
{
return $this->identifier;
}
/**
* @return string|null
*/
public function getTargetClass(): ?string
{
return $this->targetClass;
}
/**
* @return string|null
*/
public function getTarget(): ?string
{
return $this->target;
}
/**
* @return array
*/
public function getChanges(): array
{
return $this->changes;
}
/**
* @return string|null
*/
public function getUser(): ?string
{
return $this->user;

View File

@ -56,9 +56,6 @@ class CustomField
*/
protected $auto_assign;
/**
* @return int
*/
public function getId(): int
{
return $this->id;
@ -66,7 +63,6 @@ class CustomField
/**
* @AuditLog\AuditIdentifier()
*
* @return string
*/
public function getName(): string
@ -74,21 +70,15 @@ class CustomField
return $this->name;
}
/**
* @param string $name
*/
public function setName(string $name): void
{
$this->name = $this->_truncateString($name);
$this->name = $this->truncateString($name);
if (empty($this->short_name) && !empty($name)) {
$this->setShortName(Station::getStationShortName($name));
}
}
/**
* @return null|string
*/
public function getShortName(): ?string
{
return (!empty($this->short_name))
@ -96,36 +86,24 @@ class CustomField
: Station::getStationShortName($this->name);
}
/**
* @param null|string $short_name
*/
public function setShortName(?string $short_name): void
{
$short_name = trim($short_name);
if (!empty($short_name)) {
$this->short_name = $this->_truncateString($short_name, 100);
$this->short_name = $this->truncateString($short_name, 100);
}
}
/**
* @return string|null
*/
public function getAutoAssign(): ?string
{
return $this->auto_assign;
}
/**
* @return bool
*/
public function hasAutoAssign(): bool
{
return !empty($this->auto_assign);
}
/**
* @param string|null $auto_assign
*/
public function setAutoAssign(?string $auto_assign): void
{
$this->auto_assign = $auto_assign;

View File

@ -73,13 +73,7 @@ class Listener
*/
protected $timestamp_end;
/**
* Listener constructor.
*
* @param Station $station
* @param array $client
*/
public function __construct(Station $station, $client)
public function __construct(Station $station, array $client)
{
$this->station = $station;
@ -87,19 +81,64 @@ class Listener
$this->timestamp_end = 0;
$this->listener_uid = $client['uid'];
$this->listener_user_agent = $this->_truncateString($client['user_agent']) ?? '';
$this->listener_user_agent = $this->truncateString($client['user_agent']) ?? '';
$this->listener_ip = $client['ip'];
$this->listener_hash = self::calculateListenerHash($client);
}
/**
* @param array $client
*
* @return string
*/
public static function calculateListenerHash($client): string
public function getId(): int
{
return md5($client['ip'] . $client['user_agent']);
return $this->id;
}
public function getStation(): Station
{
return $this->station;
}
public function getListenerUid(): int
{
return $this->listener_uid;
}
public function getListenerIp(): string
{
return $this->listener_ip;
}
public function getListenerUserAgent(): string
{
return $this->listener_user_agent;
}
public function getListenerHash(): string
{
return $this->listener_hash;
}
public function getTimestampStart(): int
{
return $this->timestamp_start;
}
public function getTimestamp(): int
{
return $this->timestamp_start;
}
public function getTimestampEnd(): int
{
return $this->timestamp_end;
}
public function setTimestampEnd(int $timestamp_end): void
{
$this->timestamp_end = $timestamp_end;
}
public function getConnectedSeconds(): int
{
return $this->timestamp_end - $this->timestamp_start;
}
/**
@ -117,94 +156,6 @@ class Listener
});
}
/**
* @return int
*/
public function getId(): int
{
return $this->id;
}
/**
* @return Station
*/
public function getStation(): Station
{
return $this->station;
}
/**
* @return int
*/
public function getListenerUid(): int
{
return $this->listener_uid;
}
/**
* @return string
*/
public function getListenerIp(): string
{
return $this->listener_ip;
}
/**
* @return string
*/
public function getListenerUserAgent(): string
{
return $this->listener_user_agent;
}
/**
* @return string
*/
public function getListenerHash(): string
{
return $this->listener_hash;
}
/**
* @return int
*/
public function getTimestampStart(): int
{
return $this->timestamp_start;
}
/**
* @return int
*/
public function getTimestamp(): int
{
return $this->timestamp_start;
}
/**
* @return int
*/
public function getTimestampEnd(): int
{
return $this->timestamp_end;
}
/**
* @param int $timestamp_end
*/
public function setTimestampEnd(int $timestamp_end): void
{
$this->timestamp_end = $timestamp_end;
}
/**
* @return int
*/
public function getConnectedSeconds(): int
{
return $this->timestamp_end - $this->timestamp_start;
}
public static function getListenerSeconds(array $intervals): int
{
// Sort by start time.
@ -238,4 +189,9 @@ class Listener
return $seconds;
}
}
public static function calculateListenerHash(array $client): string
{
return md5($client['ip'] . $client['user_agent']);
}
}

View File

@ -82,12 +82,9 @@ class Relay
*/
protected $remotes;
/**
* @param string $base_url
*/
public function __construct(string $base_url)
{
$this->base_url = $this->_truncateString($base_url);
$this->base_url = $this->truncateString($base_url);
$this->created_at = time();
$this->updated_at = time();
@ -103,105 +100,66 @@ class Relay
$this->updated_at = time();
}
/**
* @return int
*/
public function getId(): int
{
return $this->id;
}
/**
* @return string
*/
public function getBaseUrl(): ?string
{
return $this->base_url;
}
/**
* @return string|null
*/
public function getName(): ?string
{
return $this->name;
}
/**
* @param string|null $name
*/
public function setName(?string $name): void
{
$this->name = $this->_truncateString($name, 100);
$this->name = $this->truncateString($name, 100);
}
/**
* @return bool
*/
public function isIsVisibleOnPublicPages(): bool
{
return $this->is_visible_on_public_pages;
}
/**
* @param bool $is_visible_on_public_pages
*/
public function setIsVisibleOnPublicPages(bool $is_visible_on_public_pages): void
{
$this->is_visible_on_public_pages = $is_visible_on_public_pages;
}
/**
* @return mixed|null
*/
public function getNowplaying()
{
return $this->nowplaying;
}
/**
* @param mixed|null $nowplaying
*/
public function setNowplaying($nowplaying): void
{
$this->nowplaying = $nowplaying;
}
/**
* @return int
*/
public function getCreatedAt(): int
{
return $this->created_at;
}
/**
* @param int $created_at
*/
public function setCreatedAt(int $created_at): void
{
$this->created_at = $created_at;
}
/**
* @return int
*/
public function getUpdatedAt(): int
{
return $this->updated_at;
}
/**
* @param int $updated_at
*/
public function setUpdatedAt(int $updated_at): void
{
$this->updated_at = $updated_at;
}
/**
* @return Collection
*/
public function getRemotes(): Collection
{
return $this->remotes;

View File

@ -1,10 +1,10 @@
<?php
namespace App\Entity\Repository;
use App\Doctrine\Repository;
use App\Entity;
use App\Exception\MediaProcessingException;
use App\Radio\Filesystem;
use App\Doctrine\Repository;
use App\Settings;
use Doctrine\ORM\EntityManager;
use Doctrine\ORM\ORMException;
@ -19,14 +19,11 @@ use voku\helper\UTF8;
class StationMediaRepository extends Repository
{
/** @var Filesystem */
protected $filesystem;
protected Filesystem $filesystem;
/** @var SongRepository */
protected $songRepo;
protected SongRepository $songRepo;
/** @var CustomFieldRepository */
protected $customFieldRepo;
protected CustomFieldRepository $customFieldRepo;
public function __construct(
EntityManager $em,

View File

@ -1,6 +1,7 @@
<?php
namespace App\Entity\Repository;
use App\Doctrine\Repository;
use App\Entity;
use App\Radio\Adapters;
use App\Radio\Configuration;
@ -8,7 +9,6 @@ use App\Radio\Frontend\AbstractFrontend;
use App\Settings;
use App\Sync\Task\Media;
use App\Utilities;
use App\Doctrine\Repository;
use Closure;
use Doctrine\ORM\EntityManager;
use Exception;
@ -19,20 +19,15 @@ use Symfony\Component\Validator\Validator\ValidatorInterface;
class StationRepository extends Repository
{
/** @var Media */
protected $media_sync;
protected Media $media_sync;
/** @var Adapters */
protected $adapters;
protected Adapters $adapters;
/** @var Configuration */
protected $configuration;
protected Configuration $configuration;
/** @var ValidatorInterface */
protected $validator;
protected ValidatorInterface $validator;
/** @var CacheInterface */
protected $cache;
protected CacheInterface $cache;
public function __construct(
EntityManager $em,

View File

@ -6,8 +6,6 @@ use App\Entity;
class StationScheduleRepository extends Repository
{
/**
* @param Entity\StationPlaylist|Entity\StationStreamer $relation
* @param array|null $items

View File

@ -53,18 +53,12 @@ class Role implements JsonSerializable
*/
protected $permissions;
/**
* Role constructor.
*/
public function __construct()
{
$this->users = new ArrayCollection;
$this->permissions = new ArrayCollection;
}
/**
* @return int
*/
public function getId(): int
{
return $this->id;
@ -72,7 +66,6 @@ class Role implements JsonSerializable
/**
* @AuditLog\AuditIdentifier()
*
* @return string
*/
public function getName(): string
@ -80,25 +73,16 @@ class Role implements JsonSerializable
return $this->name;
}
/**
* @param string $name
*/
public function setName(string $name): void
{
$this->name = $this->_truncateString($name, 100);
$this->name = $this->truncateString($name, 100);
}
/**
* @return Collection
*/
public function getUsers(): Collection
{
return $this->users;
}
/**
* @return Collection
*/
public function getPermissions(): Collection
{
return $this->permissions;

View File

@ -56,13 +56,6 @@ class RolePermission implements JsonSerializable
*/
protected $station;
/**
* RolePermission constructor.
*
* @param Role $role
* @param Station|null $station
* @param null $action_name
*/
public function __construct(Role $role, Station $station = null, $action_name = null)
{
$this->role = $role;
@ -73,49 +66,31 @@ class RolePermission implements JsonSerializable
}
}
/**
* @return int
*/
public function getId(): int
{
return $this->id;
}
/**
* @return Role
*/
public function getRole(): Role
{
return $this->role;
}
/**
* @return Station|null
*/
public function getStation(): ?Station
{
return $this->station;
}
/**
* @return bool
*/
public function hasStation(): bool
{
return (null !== $this->station);
}
/**
* @return string
*/
public function getActionName(): string
{
return $this->action_name;
}
/**
* @param string $action_name
*/
public function setActionName(string $action_name)
{
$this->action_name = $action_name;

View File

@ -16,7 +16,7 @@ class Settings
public const PREFER_BROWSER_URL = 'prefer_browser_url';
public const USE_RADIO_PROXY = 'use_radio_proxy';
public const HISTORY_KEEP_DAYS = 'history_keep_days';
public const ALWAYS_USE_SSL = 'always_use_ssl';
public const API_ACCESS_CONTROL = 'api_access_control';
public const NOWPLAYING_USE_WEBSOCKETS = 'nowplaying_use_websockets';
@ -81,44 +81,26 @@ class Settings
*/
protected $setting_value;
/**
* Settings constructor.
*
* @param string $setting_key
*/
public function __construct(string $setting_key)
{
$this->setting_key = $setting_key;
}
/**
* @return string
*/
public function getSettingKey(): string
{
return $this->setting_key;
}
/**
* @return mixed
*/
public function getSettingValue()
{
return $this->setting_value;
}
/**
* @param mixed $setting_value
*/
public function setSettingValue($setting_value)
{
$this->setting_value = $setting_value;
}
/**
* @return mixed
* @see getSettingValue
*/
public function getValue()
{
return $this->setting_value;

View File

@ -70,11 +70,6 @@ class Song
*/
protected $history;
/**
* Song constructor.
*
* @param array $song_info
*/
public function __construct(array $song_info)
{
@ -99,9 +94,9 @@ class Song
}
}
$this->text = $this->_truncateString($song_info['text'], 150);
$this->title = $this->_truncateString($song_info['title'], 150);
$this->artist = $this->_truncateString($song_info['artist'], 150);
$this->text = $this->truncateString($song_info['text'], 150);
$this->title = $this->truncateString($song_info['title'], 150);
$this->artist = $this->truncateString($song_info['artist'], 150);
$new_song_hash = self::getSongHash($song_info);
@ -148,57 +143,36 @@ class Song
return md5($hash_base);
}
/**
* @return string|null
*/
public function getText(): ?string
{
return $this->text;
}
/**
* @return string|null
*/
public function getArtist(): ?string
{
return $this->artist;
}
/**
* @return string|null
*/
public function getTitle(): ?string
{
return $this->title;
}
/**
* @return string
*/
public function getId(): string
{
return $this->id;
}
/**
* @return int
*/
public function getCreated(): int
{
return $this->created;
}
/**
* @return int
*/
public function getPlayCount(): int
{
return $this->play_count;
}
/**
* @return int
*/
public function getLastPlayed(): int
{
return $this->last_played;
@ -213,17 +187,11 @@ class Song
$this->last_played = time();
}
/**
* @return Collection
*/
public function getHistory(): Collection
{
return $this->history;
}
/**
* @return string A string identifying this entity.
*/
public function __toString(): string
{
return 'Song ' . $this->id . ': ' . $this->artist . ' - ' . $this->title;

View File

@ -218,73 +218,46 @@ class SongHistory
$this->delta_positive = 0;
}
/**
* @return int
*/
public function getId(): int
{
return $this->id;
}
/**
* @return Song
*/
public function getSong(): Song
{
return $this->song;
}
/**
* @return Station
*/
public function getStation(): Station
{
return $this->station;
}
/**
* @return StationPlaylist|null
*/
public function getPlaylist(): ?StationPlaylist
{
return $this->playlist;
}
/**
* @param StationPlaylist|null $playlist
*/
public function setPlaylist(StationPlaylist $playlist = null): void
{
$this->playlist = $playlist;
}
/**
* @return StationStreamer|null
*/
public function getStreamer(): ?StationStreamer
{
return $this->streamer;
}
/**
* @param StationStreamer|null $streamer
*/
public function setStreamer(?StationStreamer $streamer): void
{
$this->streamer = $streamer;
}
/**
* @return StationMedia|null
*/
public function getMedia(): ?StationMedia
{
return $this->media;
}
/**
* @param StationMedia|null $media
*/
public function setMedia(StationMedia $media = null): void
{
$this->media = $media;
@ -294,57 +267,36 @@ class SongHistory
}
}
/**
* @return StationRequest|null
*/
public function getRequest(): ?StationRequest
{
return $this->request;
}
/**
* @param StationRequest|null $request
*/
public function setRequest($request): void
{
$this->request = $request;
}
/**
* @return string|null
*/
public function getAutodjCustomUri(): ?string
{
return $this->autodj_custom_uri;
}
/**
* @param string|null $autodj_custom_uri
*/
public function setAutodjCustomUri(?string $autodj_custom_uri): void
{
$this->autodj_custom_uri = $autodj_custom_uri;
}
/**
* @return int|null
*/
public function getTimestampCued(): ?int
{
return $this->timestamp_cued;
}
/**
* @param int|null $timestamp_cued
*/
public function setTimestampCued($timestamp_cued): void
{
$this->timestamp_cued = $timestamp_cued;
}
/**
* @return bool
*/
public function getSentToAutodj(): bool
{
return $this->sent_to_autodj;
@ -360,65 +312,41 @@ class SongHistory
$this->sent_to_autodj = true;
}
/**
* @return int
*/
public function getTimestampStart(): int
{
return $this->timestamp_start;
}
/**
* @param int $timestamp_start
*/
public function setTimestampStart(int $timestamp_start): void
{
$this->timestamp_start = $timestamp_start;
}
/**
* @return int|null
*/
public function getDuration(): ?int
{
return $this->duration;
}
/**
* @param int|null $duration
*/
public function setDuration($duration): void
{
$this->duration = $duration;
}
/**
* @return int|null
*/
public function getListenersStart(): ?int
{
return $this->listeners_start;
}
/**
* @param int|null $listeners_start
*/
public function setListenersStart($listeners_start): void
{
$this->listeners_start = $listeners_start;
}
/**
* @return int
*/
public function getTimestampEnd(): int
{
return $this->timestamp_end;
}
/**
* @param int $timestamp_end
*/
public function setTimestampEnd(int $timestamp_end): void
{
$this->timestamp_end = $timestamp_end;
@ -428,113 +356,71 @@ class SongHistory
}
}
/**
* @return int
*/
public function getTimestamp(): int
{
return (int)$this->timestamp_start;
}
/**
* @return int|null
*/
public function getListenersEnd(): ?int
{
return $this->listeners_end;
}
/**
* @param int|null $listeners_end
*/
public function setListenersEnd($listeners_end): void
{
$this->listeners_end = $listeners_end;
}
/**
* @return int|null
*/
public function getUniqueListeners(): ?int
{
return $this->unique_listeners;
}
/**
* @param int|null $unique_listeners
*/
public function setUniqueListeners($unique_listeners): void
{
$this->unique_listeners = $unique_listeners;
}
/**
* @return int
*/
public function getListeners(): int
{
return (int)$this->listeners_start;
}
/**
* @return int
*/
public function getDeltaTotal(): int
{
return $this->delta_total;
}
/**
* @param int $delta_total
*/
public function setDeltaTotal(int $delta_total): void
{
$this->delta_total = $this->_truncateSmallInt($delta_total);
}
/**
* @return int
*/
public function getDeltaPositive(): int
{
return $this->delta_positive;
}
/**
* @param int $delta_positive
*/
public function setDeltaPositive(int $delta_positive): void
{
$this->delta_positive = $this->_truncateSmallInt($delta_positive);
}
/**
* @return int
*/
public function getDeltaNegative(): int
{
return $this->delta_negative;
}
/**
* @param int $delta_negative
*/
public function setDeltaNegative(int $delta_negative): void
{
$this->delta_negative = $this->_truncateSmallInt($delta_negative);
}
/**
* @return mixed|null
*/
public function getDeltaPoints()
{
return $this->delta_points;
}
/**
* @param mixed $delta_point
*/
public function addDeltaPoint($delta_point): void
{
$delta_points = (array)$this->delta_points;

View File

@ -399,37 +399,25 @@ class Station
$this->sftp_users = new ArrayCollection;
}
/**
* @return int|null
*/
public function getId(): ?int
{
return $this->id;
}
/**
* @return null|string
*/
public function getName(): ?string
{
return $this->name;
}
/**
* @param null|string $name
*/
public function setName(?string $name = null): void
{
$this->name = $this->_truncateString($name, 100);
$this->name = $this->truncateString($name, 100);
if (empty($this->short_name) && !empty($name)) {
$this->setShortName($name);
}
}
/**
* @return null|string
*/
public function getShortName(): ?string
{
return (!empty($this->short_name))
@ -437,15 +425,12 @@ class Station
: self::getStationShortName($this->name);
}
/**
* @param null|string $short_name
*/
public function setShortName(?string $short_name): void
{
$short_name = trim($short_name);
if (!empty($short_name)) {
$short_name = self::getStationShortName($short_name);
$this->short_name = $this->_truncateString($short_name, 100);
$this->short_name = $this->truncateString($short_name, 100);
}
}
@ -454,42 +439,26 @@ class Station
return File::sanitizeFileName($str);
}
/**
* @param bool $is_enabled
*/
public function setIsEnabled(bool $is_enabled): void
{
$this->is_enabled = $is_enabled;
}
/**
* @return null|string
*/
public function getFrontendType(): ?string
{
return $this->frontend_type;
}
/**
* @param null|string $frontend_type
*/
public function setFrontendType(string $frontend_type = null): void
public function setFrontendType(?string $frontend_type = null): void
{
$this->frontend_type = $frontend_type;
}
/**
* @return array|null
*/
public function getFrontendConfig(): ?array
{
return $this->frontend_config;
}
/**
* @param array $frontend_config
* @param bool $force_overwrite
*/
public function setFrontendConfig(array $frontend_config, $force_overwrite = false): void
{
$config = ($force_overwrite) ? [] : (array)$this->frontend_config;
@ -522,17 +491,11 @@ class Station
$this->frontend_config = $frontend_config;
}
/**
* @return null|string
*/
public function getBackendType(): ?string
{
return $this->backend_type;
}
/**
* @param null|string $backend_type
*/
public function setBackendType(string $backend_type = null): void
{
$this->backend_type = $backend_type;
@ -565,18 +528,11 @@ class Station
return (bool)($settings['use_manual_autodj'] ?? false);
}
/**
* @return array|null
*/
public function getBackendConfig(): ?array
{
return $this->backend_config;
}
/**
* @param array $backend_config
* @param bool $force_overwrite
*/
public function setBackendConfig(array $backend_config, $force_overwrite = false): void
{
$config = ($force_overwrite) ? [] : (array)$this->backend_config;
@ -591,9 +547,6 @@ class Station
$this->backend_config = $config;
}
/**
* @return null|string
*/
public function getAdapterApiKey(): ?string
{
return $this->adapter_api_key;
@ -619,68 +572,44 @@ class Station
return hash_equals($api_key, $this->adapter_api_key);
}
/**
* @return null|string
*/
public function getDescription(): ?string
{
return $this->description;
}
/**
* @param null|string $description
*/
public function setDescription(string $description = null): void
{
$this->description = $description;
}
/**
* @return null|string
*/
public function getUrl(): ?string
{
return $this->url;
}
/**
* @param null|string $url
*/
public function setUrl(string $url = null): void
{
$this->url = $this->_truncateString($url);
$this->url = $this->truncateString($url);
}
/**
* @return string|null
*/
public function getGenre(): ?string
{
return $this->genre;
}
/**
* @param string|null $genre
*/
public function setGenre(?string $genre): void
{
$this->genre = $this->_truncateString($genre, 150);
$this->genre = $this->truncateString($genre, 150);
}
/**
* @return null|string
*/
public function getRadioBaseDir(): ?string
{
return $this->radio_base_dir;
}
/**
* @param string $new_dir
*/
public function setRadioBaseDir($new_dir): void
{
$this->radio_base_dir = $this->_truncateString(trim($new_dir));
$this->radio_base_dir = $this->truncateString(trim($new_dir));
}
public function getRadioAlbumArtDir(): string
@ -710,9 +639,6 @@ class Station
return ltrim(str_replace($this->getRadioMediaDir(), '', $full_path), '/');
}
/**
* @return string
*/
public function getRadioMediaDir(): string
{
return (!empty($this->radio_media_dir))
@ -720,12 +646,9 @@ class Station
: $this->radio_base_dir . '/media';
}
/**
* @param string $new_dir
*/
public function setRadioMediaDir(?string $new_dir): void
{
$new_dir = $this->_truncateString(trim($new_dir));
$new_dir = $this->truncateString(trim($new_dir));
if ($new_dir && $new_dir !== $this->radio_media_dir) {
if (!empty($new_dir) && !file_exists($new_dir) && !mkdir($new_dir, 0777, true) && !is_dir($new_dir)) {
@ -736,25 +659,16 @@ class Station
}
}
/**
* @return string
*/
public function getRadioPlaylistsDir(): string
{
return $this->radio_base_dir . '/playlists';
}
/**
* @return string
*/
public function getRadioConfigDir(): string
{
return $this->radio_base_dir . '/config';
}
/**
* @return Api\NowPlaying|null
*/
public function getNowplaying(): ?Api\NowPlaying
{
if ($this->nowplaying instanceof Api\NowPlaying) {
@ -763,9 +677,6 @@ class Station
return null;
}
/**
* @param Api\NowPlaying|null $nowplaying
*/
public function setNowplaying(Api\NowPlaying $nowplaying = null): void
{
$this->nowplaying = $nowplaying;
@ -775,129 +686,81 @@ class Station
}
}
/**
* @return int
*/
public function getNowplayingTimestamp(): int
{
return (int)$this->nowplaying_timestamp;
}
/**
* @param int $nowplaying_timestamp
*/
public function setNowPlayingTimestamp(int $nowplaying_timestamp): void
{
$this->nowplaying_timestamp = $nowplaying_timestamp;
}
/**
* @return array|null
*/
public function getAutomationSettings(): ?array
{
return $this->automation_settings;
}
/**
* @param array|null $automation_settings
*/
public function setAutomationSettings(array $automation_settings = null): void
{
$this->automation_settings = $automation_settings;
}
/**
* @return int|null
*/
public function getAutomationTimestamp(): ?int
{
return $this->automation_timestamp;
}
/**
* @param int|null $automation_timestamp
*/
public function setAutomationTimestamp(int $automation_timestamp = null): void
{
$this->automation_timestamp = $automation_timestamp;
}
/**
* @return bool
*/
public function getEnableRequests(): bool
{
return $this->enable_requests;
}
/**
* @param bool $enable_requests
*/
public function setEnableRequests(bool $enable_requests): void
{
$this->enable_requests = $enable_requests;
}
/**
* @return int|null
*/
public function getRequestDelay(): ?int
{
return $this->request_delay;
}
/**
* @param int|null $request_delay
*/
public function setRequestDelay(int $request_delay = null): void
{
$this->request_delay = $request_delay;
}
/**
* @return int|null
*/
public function getRequestThreshold(): ?int
{
return $this->request_threshold;
}
/**
* @param int|null $request_threshold
*/
public function setRequestThreshold(int $request_threshold = null): void
{
$this->request_threshold = $request_threshold;
}
/**
* @return int
*/
public function getDisconnectDeactivateStreamer(): int
{
return $this->disconnect_deactivate_streamer;
}
/**
* @param int $disconnect_deactivate_streamer
*/
public function setDisconnectDeactivateStreamer(int $disconnect_deactivate_streamer): void
{
$this->disconnect_deactivate_streamer = $disconnect_deactivate_streamer;
}
/**
* @return bool
*/
public function getEnableStreamers(): bool
{
return $this->enable_streamers;
}
/**
* @param bool $enable_streamers
*/
public function setEnableStreamers(bool $enable_streamers): void
{
if ($this->enable_streamers !== $enable_streamers) {
@ -907,97 +770,61 @@ class Station
$this->enable_streamers = $enable_streamers;
}
/**
* @return bool
*/
public function getIsStreamerLive(): bool
{
return $this->is_streamer_live;
}
/**
* @param bool $is_streamer_live
*/
public function setIsStreamerLive(bool $is_streamer_live): void
{
$this->is_streamer_live = $is_streamer_live;
}
/**
* @return bool
*/
public function getEnablePublicPage(): bool
{
return (bool)$this->enable_public_page && $this->isEnabled();
}
/**
* @param bool $enable_public_page
*/
public function setEnablePublicPage(bool $enable_public_page): void
{
$this->enable_public_page = $enable_public_page;
}
/**
* @return bool
*/
public function isEnabled(): bool
{
return $this->is_enabled;
}
/**
* @return bool
*/
public function getNeedsRestart(): bool
{
return $this->needs_restart;
}
/**
* @param bool $needs_restart
*/
public function setNeedsRestart(bool $needs_restart): void
{
$this->needs_restart = $needs_restart;
}
/**
* @return bool
*/
public function getHasStarted(): bool
{
return $this->has_started;
}
/**
* @param bool $has_started
*/
public function setHasStarted(bool $has_started): void
{
$this->has_started = $has_started;
}
/**
* @return int
*/
public function getApiHistoryItems(): int
{
return $this->api_history_items ?? self::DEFAULT_API_HISTORY_ITEMS;
}
/**
* @param int|null $api_history_items
*/
public function setApiHistoryItems(?int $api_history_items): void
{
$this->api_history_items = $api_history_items;
}
/**
* @return string|null
*/
public function getStorageQuota(): ?string
{
$raw_quota = $this->getStorageQuotaBytes();
@ -1016,9 +843,6 @@ class Station
$this->storage_quota = !empty($storage_quota) ? $storage_quota : null;
}
/**
* @return BigInteger|null
*/
public function getStorageQuotaBytes(): ?BigInteger
{
$size = $this->storage_quota;
@ -1028,9 +852,6 @@ class Station
: null;
}
/**
* @return string|null
*/
public function getStorageUsed(): ?string
{
$raw_size = $this->getStorageUsedBytes();
@ -1049,9 +870,6 @@ class Station
$this->storage_used = !empty($storage_used) ? $storage_used : null;
}
/**
* @return BigInteger
*/
public function getStorageUsedBytes(): BigInteger
{
$size = $this->storage_used;
@ -1098,9 +916,6 @@ class Station
$this->storage_used = (string)$storage_used;
}
/**
* @return string
*/
public function getStorageAvailable(): string
{
$raw_size = $this->getRawStorageAvailable();
@ -1110,9 +925,6 @@ class Station
: '';
}
/**
* @return BigInteger|null
*/
public function getRawStorageAvailable(): ?BigInteger
{
$quota = $this->getStorageQuotaBytes();
@ -1125,9 +937,6 @@ class Station
return $quota;
}
/**
* @return bool
*/
public function isStorageFull(): bool
{
$available = $this->getRawStorageAvailable();
@ -1143,17 +952,11 @@ class Station
return ($used->compareTo($available) !== -1);
}
/**
* @return int
*/
public function getStorageUsePercentage(): int
{
return Quota::getPercentage($this->getStorageUsedBytes(), $this->getRawStorageAvailable());
}
/**
* @return string
*/
public function getTimezone(): string
{
if (!empty($this->timezone)) {
@ -1163,49 +966,31 @@ class Station
return Customization::DEFAULT_TIMEZONE;
}
/**
* @param string|null $timezone
*/
public function setTimezone(?string $timezone): void
{
$this->timezone = $timezone;
}
/**
* @return Collection
*/
public function getHistory(): Collection
{
return $this->history;
}
/**
* @return Collection
*/
public function getMedia(): Collection
{
return $this->media;
}
/**
* @return Collection
*/
public function getStreamers(): Collection
{
return $this->streamers;
}
/**
* @return StationStreamer|null
*/
public function getCurrentStreamer(): ?StationStreamer
{
return $this->current_streamer;
}
/**
* @param StationStreamer|null $current_streamer
*/
public function setCurrentStreamer(?StationStreamer $current_streamer = null): void
{
if (null !== $this->current_streamer || null !== $current_streamer) {
@ -1213,49 +998,31 @@ class Station
}
}
/**
* @return Collection
*/
public function getPermissions(): Collection
{
return $this->permissions;
}
/**
* @return Collection
*/
public function getPlaylists(): Collection
{
return $this->playlists;
}
/**
* @return Collection
*/
public function getMounts(): Collection
{
return $this->mounts;
}
/**
* @return Collection
*/
public function getRemotes(): Collection
{
return $this->remotes;
}
/**
* @return Collection
*/
public function getWebhooks(): Collection
{
return $this->webhooks;
}
/**
* @return Collection
*/
public function getSftpUsers(): Collection
{
return $this->sftp_users;

View File

@ -252,90 +252,57 @@ class StationMedia
$this->generateUniqueId();
}
/**
* @return int
*/
public function getId(): int
{
return $this->id;
}
/**
* @return Station
*/
public function getStation(): Station
{
return $this->station;
}
/**
* @return string|null
*/
public function getSongId(): ?string
{
return $this->song_id;
}
/**
* @return null|string
*/
public function getTitle(): ?string
{
return $this->title;
}
/**
* @param null|string $title
*/
public function setTitle(string $title = null): void
public function setTitle(?string $title = null): void
{
$this->title = $this->_truncateString($title, 200);
$this->title = $this->truncateString($title, 200);
}
/**
* @return null|string
*/
public function getArtist(): ?string
{
return $this->artist;
}
/**
* @param null|string $artist
*/
public function setArtist(string $artist = null): void
public function setArtist(?string $artist = null): void
{
$this->artist = $this->_truncateString($artist, 200);
$this->artist = $this->truncateString($artist, 200);
}
/**
* @return null|string
*/
public function getAlbum(): ?string
{
return $this->album;
}
/**
* @param null|string $album
*/
public function setAlbum(string $album = null): void
public function setAlbum(?string $album = null): void
{
$this->album = $this->_truncateString($album, 200);
$this->album = $this->truncateString($album, 200);
}
/**
* @return null|string
*/
public function getLyrics(): ?string
{
return $this->lyrics;
}
/**
* @param null|string $lyrics
*/
public function setLyrics($lyrics): void
public function setLyrics(?string $lyrics = null): void
{
$this->lyrics = $lyrics;
}
@ -350,25 +317,16 @@ class StationMedia
return 'albumart://' . $this->unique_id . '.jpg';
}
/**
* @return null|string
*/
public function getIsrc(): ?string
{
return $this->isrc;
}
/**
* @param null|string $isrc
*/
public function setIsrc(string $isrc = null): void
public function setIsrc(?string $isrc = null): void
{
$this->isrc = $isrc;
}
/**
* @return int
*/
public function getLength(): int
{
return $this->length;
@ -386,34 +344,22 @@ class StationMedia
$this->length_text = $length_min . ':' . str_pad($length_sec, 2, '0', STR_PAD_LEFT);
}
/**
* @return null|string
*/
public function getLengthText(): ?string
{
return $this->length_text;
}
/**
* @param null|string $length_text
*/
public function setLengthText(string $length_text = null): void
public function setLengthText(?string $length_text = null): void
{
$this->length_text = $length_text;
}
/**
* @return null|string
*/
public function getPath(): ?string
{
return $this->path;
}
/**
* @param null|string $path
*/
public function setPath(string $path = null): void
public function setPath(?string $path = null): void
{
$this->path = $path;
}
@ -428,34 +374,22 @@ class StationMedia
return 'media://' . $this->path;
}
/**
* @return int|null
*/
public function getMtime(): ?int
{
return $this->mtime;
}
/**
* @param int|null $mtime
*/
public function setMtime(int $mtime = null): void
public function setMtime(?int $mtime = null): void
{
$this->mtime = $mtime;
}
/**
* @return float|null
*/
public function getAmplify(): ?float
{
return $this->amplify;
}
/**
* @param float|null $amplify
*/
public function setAmplify($amplify = null): void
public function setAmplify(?float $amplify = null): void
{
if ($amplify === '') {
$amplify = null;
@ -464,18 +398,12 @@ class StationMedia
$this->amplify = (null === $amplify) ? null : (float)$amplify;
}
/**
* @return float|null
*/
public function getFadeOverlap(): ?float
{
return $this->fade_overlap;
}
/**
* @param float|null $fade_overlap
*/
public function setFadeOverlap($fade_overlap = null): void
public function setFadeOverlap(?float $fade_overlap = null): void
{
if ($fade_overlap === '') {
$fade_overlap = null;
@ -484,9 +412,6 @@ class StationMedia
$this->fade_overlap = $fade_overlap;
}
/**
* @return float|null
*/
public function getFadeIn(): ?float
{
return $this->fade_in;
@ -500,9 +425,6 @@ class StationMedia
$this->fade_in = $this->parseSeconds($fade_in);
}
/**
* @return float|null
*/
public function getFadeOut(): ?float
{
return $this->fade_out;
@ -516,9 +438,6 @@ class StationMedia
$this->fade_out = $this->parseSeconds($fade_out);
}
/**
* @return float|null
*/
public function getCueIn(): ?float
{
return $this->cue_in;
@ -532,9 +451,6 @@ class StationMedia
$this->cue_in = $this->parseSeconds($cue_in);
}
/**
* @return float|null
*/
public function getCueOut(): ?float
{
return $this->cue_out;
@ -591,27 +507,16 @@ class StationMedia
return $length;
}
/**
* @return int
*/
public function getArtUpdatedAt(): int
{
return $this->art_updated_at;
}
/**
* @param int $art_updated_at
*/
public function setArtUpdatedAt(int $art_updated_at): void
{
$this->art_updated_at = $art_updated_at;
}
/**
* @param StationPlaylist $playlist
*
* @return StationPlaylistMedia|null
*/
public function getItemForPlaylist(StationPlaylist $playlist): ?StationPlaylistMedia
{
$item = $this->playlists->filter(function ($spm) use ($playlist) {
@ -626,17 +531,11 @@ class StationMedia
: null;
}
/**
* @return Collection
*/
public function getCustomFields(): Collection
{
return $this->custom_fields;
}
/**
* @param Collection $custom_fields
*/
public function setCustomFields(Collection $custom_fields): void
{
$this->custom_fields = $custom_fields;
@ -747,18 +646,12 @@ class StationMedia
return $annotations;
}
/**
* @return Song|null
*/
public function getSong(): ?Song
{
return $this->song;
}
/**
* @param Song|null $song
*/
public function setSong(Song $song = null): void
public function setSong(?Song $song = null): void
{
$this->song = $song;
}
@ -782,17 +675,11 @@ class StationMedia
return false;
}
/**
* @return Collection
*/
public function getPlaylists(): Collection
{
return $this->playlists;
}
/**
* @return string A string identifying this entity.
*/
public function __toString(): string
{
return 'StationMedia ' . $this->unique_id . ': ' . $this->artist . ' - ' . $this->title;

View File

@ -57,35 +57,23 @@ class StationMediaCustomField
$this->field = $field;
}
/**
* @return StationMedia
*/
public function getMedia(): StationMedia
{
return $this->media;
}
/**
* @return CustomField
*/
public function getField(): CustomField
{
return $this->field;
}
/**
* @return string|null
*/
public function getValue(): ?string
{
return $this->value;
}
/**
* @param string|null $value
*/
public function setValue($value): void
public function setValue(?string $value = null): void
{
$this->value = $this->_truncateString($value);
$this->value = $this->truncateString($value);
}
}

View File

@ -188,17 +188,11 @@ class StationMount implements StationMountInterface
$this->station = $station;
}
/**
* @return int
*/
public function getId(): int
{
return $this->id;
}
/**
* @return bool
*/
public function isVisibleOnPublicPages(): bool
{
if ($this->is_default) {
@ -208,201 +202,126 @@ class StationMount implements StationMountInterface
return $this->is_visible_on_public_pages;
}
/**
* @param bool $is_visible_on_public_pages
*/
public function setIsVisibleOnPublicPages(bool $is_visible_on_public_pages): void
{
$this->is_visible_on_public_pages = $is_visible_on_public_pages;
}
/**
* @return bool
*/
public function getIsDefault(): bool
{
return $this->is_default;
}
/**
* @param bool $is_default
*/
public function setIsDefault(bool $is_default): void
{
$this->is_default = $is_default;
}
/**
* @return bool
*/
public function getIsPublic(): bool
{
return $this->is_public;
}
/**
* @param bool $is_public
*/
public function setIsPublic(bool $is_public): void
{
$this->is_public = $is_public;
}
/**
* @return null|string
*/
public function getFallbackMount(): ?string
{
return $this->fallback_mount;
}
/**
* @param null|string $fallback_mount
*/
public function setFallbackMount($fallback_mount): void
public function setFallbackMount(?string $fallback_mount = null): void
{
$this->fallback_mount = $fallback_mount;
}
/**
* @return mixed
*/
public function getRelayUrl()
{
return $this->relay_url;
}
/**
* @param null|string $relay_url
*/
public function setRelayUrl(string $relay_url = null): void
public function setRelayUrl(?string $relay_url = null): void
{
$this->relay_url = $this->_truncateString($relay_url);
$this->relay_url = $this->truncateString($relay_url);
}
/**
* @return string|null
*/
public function getAuthhash(): ?string
{
return $this->authhash;
}
/**
* @param null|string $authhash
*/
public function setAuthhash(string $authhash = null): void
public function setAuthhash(?string $authhash = null): void
{
$this->authhash = $this->_truncateString($authhash);
$this->authhash = $this->truncateString($authhash);
}
/**
* @return bool
*/
public function getEnableAutodj(): bool
{
return $this->enable_autodj;
}
/**
* @param bool $enable_autodj
*/
public function setEnableAutodj(bool $enable_autodj): void
{
$this->enable_autodj = $enable_autodj;
}
/**
* @return null|string
*/
public function getAutodjFormat(): ?string
{
return $this->autodj_format;
}
/**
* @param null|string $autodj_format
*/
public function setAutodjFormat(string $autodj_format = null): void
public function setAutodjFormat(?string $autodj_format = null): void
{
$this->autodj_format = $this->_truncateString($autodj_format, 10);
$this->autodj_format = $this->truncateString($autodj_format, 10);
}
/**
* @return int|null
*/
public function getAutodjBitrate(): ?int
{
return $this->autodj_bitrate;
}
/**
* @param int|null $autodj_bitrate
*/
public function setAutodjBitrate(int $autodj_bitrate = null): void
public function setAutodjBitrate(?int $autodj_bitrate = null): void
{
$this->autodj_bitrate = $autodj_bitrate;
}
/**
* @return string|null
*/
public function getCustomListenUrl(): ?string
{
return $this->custom_listen_url;
}
/**
* @param null|string $custom_listen_url
*/
public function setCustomListenUrl(string $custom_listen_url = null): void
public function setCustomListenUrl(?string $custom_listen_url = null): void
{
$this->custom_listen_url = $this->_truncateString($custom_listen_url);
$this->custom_listen_url = $this->truncateString($custom_listen_url);
}
/**
* @return string|null
*/
public function getFrontendConfig(): ?string
{
return $this->frontend_config;
}
/**
* @param null|string $frontend_config
*/
public function setFrontendConfig(string $frontend_config = null): void
public function setFrontendConfig(?string $frontend_config = null): void
{
$this->frontend_config = $frontend_config;
}
/**
* @return int
*/
public function getListenersUnique(): int
{
return $this->listeners_unique;
}
/**
* @param int $listeners_unique
*/
public function setListenersUnique(int $listeners_unique): void
{
$this->listeners_unique = $listeners_unique;
}
/**
* @return int
*/
public function getListenersTotal(): int
{
return $this->listeners_total;
}
/**
* @param int $listeners_total
*/
public function setListenersTotal(int $listeners_total): void
{
$this->listeners_total = $listeners_total;
@ -421,9 +340,6 @@ class StationMount implements StationMountInterface
return $fe_settings['port'];
}
/**
* @return Station
*/
public function getStation(): Station
{
return $this->station;
@ -442,31 +358,21 @@ class StationMount implements StationMountInterface
return $fe_settings['source_pw'];
}
/*
* StationMountInterface compliance methods
*/
/** @inheritdoc */
public function getAutodjMount(): ?string
{
return $this->getName();
}
/**
* @return string
*/
public function getName(): string
{
return $this->name;
}
/**
* @param string $new_name
*/
public function setName(string $new_name): void
{
// Ensure all mount point names start with a leading slash.
$this->name = $this->_truncateString('/' . ltrim($new_name, '/'), 100);
$this->name = $this->truncateString('/' . ltrim($new_name, '/'), 100);
}
/** @inheritdoc */
@ -526,11 +432,8 @@ class StationMount implements StationMountInterface
return $this->name;
}
/**
* @param string|null $display_name
*/
public function setDisplayName(?string $display_name): void
{
$this->display_name = $this->_truncateString($display_name);
$this->display_name = $this->truncateString($display_name);
}
}

View File

@ -266,9 +266,6 @@ class StationPlaylist
$this->schedule_items = new ArrayCollection;
}
/**
* @return int|null
*/
public function getId(): ?int
{
return $this->id;
@ -276,7 +273,6 @@ class StationPlaylist
/**
* @AuditLog\AuditIdentifier
*
* @return string
*/
public function getName(): string
@ -284,49 +280,31 @@ class StationPlaylist
return $this->name;
}
/**
* @param string $name
*/
public function setName(string $name): void
{
$this->name = $this->_truncateString($name, 200);
$this->name = $this->truncateString($name, 200);
}
/**
* @return string
*/
public function getShortName(): string
{
return Station::getStationShortName($this->name);
}
/**
* @return string
*/
public function getType(): string
{
return $this->type;
}
/**
* @param string $type
*/
public function setType(string $type): void
{
$this->type = $type;
}
/**
* @return string
*/
public function getSource(): string
{
return $this->source;
}
/**
* @param string $source
*/
public function setSource(string $source): void
{
// Reset the playback queue if source is changed.
@ -337,17 +315,11 @@ class StationPlaylist
$this->source = $source;
}
/**
* @return string
*/
public function getOrder(): string
{
return $this->order;
}
/**
* @param string $order
*/
public function setOrder(string $order): void
{
// Reset the playback queue if order is changed.
@ -358,81 +330,51 @@ class StationPlaylist
$this->order = $order;
}
/**
* @return null|string
*/
public function getRemoteUrl(): ?string
{
return $this->remote_url;
}
/**
* @param null|string $remote_url
*/
public function setRemoteUrl(?string $remote_url): void
{
$this->remote_url = $remote_url;
}
/**
* @return string
*/
public function getRemoteType(): ?string
{
return $this->remote_type;
}
/**
* @param null|string $remote_type
*/
public function setRemoteType(?string $remote_type): void
{
$this->remote_type = $remote_type;
}
/**
* @return int
*/
public function getRemoteBuffer(): int
{
return $this->remote_buffer;
}
/**
* @param int $remote_buffer
*/
public function setRemoteBuffer(int $remote_buffer): void
{
$this->remote_buffer = $remote_buffer;
}
/**
* @return bool
*/
public function getIsEnabled(): bool
{
return $this->is_enabled;
}
/**
* @param bool $is_enabled
*/
public function setIsEnabled(bool $is_enabled): void
{
$this->is_enabled = $is_enabled;
}
/**
* @return bool
*/
public function isJingle(): bool
{
return $this->is_jingle;
}
/**
* @param bool $is_jingle
*/
public function setIsJingle(bool $is_jingle): void
{
$this->is_jingle = $is_jingle;
@ -457,9 +399,6 @@ class StationPlaylist
return 0;
}
/**
* @return int
*/
public function getWeight(): int
{
if ($this->weight < 1) {
@ -469,25 +408,16 @@ class StationPlaylist
return $this->weight;
}
/**
* @param int $weight
*/
public function setWeight(int $weight): void
{
$this->weight = $weight;
}
/**
* @return bool
*/
public function getIncludeInRequests(): bool
{
return $this->include_in_requests;
}
/**
* @param bool $include_in_requests
*/
public function setIncludeInRequests(bool $include_in_requests): void
{
$this->include_in_requests = $include_in_requests;
@ -503,33 +433,21 @@ class StationPlaylist
return ($this->is_enabled && $this->include_in_requests);
}
/**
* @return bool
*/
public function getIncludeInAutomation(): bool
{
return $this->include_in_automation;
}
/**
* @param bool $include_in_automation
*/
public function setIncludeInAutomation(bool $include_in_automation): void
{
$this->include_in_automation = $include_in_automation;
}
/**
* @return int
*/
public function getPlayedAt(): int
{
return $this->played_at;
}
/**
* @param int $played_at
*/
public function setPlayedAt(int $played_at): void
{
$this->played_at = $played_at;
@ -540,17 +458,11 @@ class StationPlaylist
$this->played_at = time();
}
/**
* @return array|null
*/
public function getQueue(): ?array
{
return $this->queue;
}
/**
* @param array|null $queue
*/
public function setQueue(?array $queue): void
{
$this->queue = $queue;
@ -586,9 +498,6 @@ class StationPlaylist
&& !$this->backendLoopPlaylistOnce());
}
/**
* @return array
*/
public function getBackendOptions(): array
{
return explode(',', $this->backend_options);
@ -685,19 +594,11 @@ class StationPlaylist
}
}
/**
* @return Station
*/
public function getStation(): Station
{
return $this->station;
}
/**
* @param Chronos $now
*
* @return bool
*/
protected function shouldPlayNowPerHour(Chronos $now): bool
{
$current_minute = (int)$now->minute;
@ -718,17 +619,11 @@ class StationPlaylist
return !$this->wasPlayedInLastXMinutes($now, 30);
}
/**
* @return int
*/
public function getPlayPerHourMinute(): int
{
return $this->play_per_hour_minute;
}
/**
* @param int $play_per_hour_minute
*/
public function setPlayPerHourMinute(int $play_per_hour_minute): void
{
if ($play_per_hour_minute > 59 || $play_per_hour_minute < 0) {
@ -748,12 +643,6 @@ class StationPlaylist
return ($this->played_at > $threshold);
}
/**
* @param array $songHistoryEntries
* @param int $length
*
* @return bool
*/
protected function wasPlayedRecently(array $songHistoryEntries = [], $length = 15): bool
{
if (empty($songHistoryEntries)) {
@ -775,49 +664,31 @@ class StationPlaylist
return $was_played;
}
/**
* @return int
*/
public function getPlayPerSongs(): int
{
return $this->play_per_songs;
}
/**
* @param int $play_per_songs
*/
public function setPlayPerSongs(int $play_per_songs): void
{
$this->play_per_songs = $play_per_songs;
}
/**
* @param Chronos $now
*
* @return bool
*/
protected function shouldPlayNowPerMinute(Chronos $now): bool
{
return !$this->wasPlayedInLastXMinutes($now, $this->getPlayPerMinutes());
}
/**
* @return int
*/
public function getPlayPerMinutes(): int
{
return $this->play_per_minutes;
}
/**
* @param int $play_per_minutes
*/
public function setPlayPerMinutes(int $play_per_minutes): void
{
$this->play_per_minutes = $play_per_minutes;
}
/**
* Export the playlist into a reusable format.
*

View File

@ -60,10 +60,6 @@ class StationPlaylistMedia implements JsonSerializable
*/
protected $last_played;
/**
* @param StationPlaylist $playlist
* @param StationMedia $media
*/
public function __construct(StationPlaylist $playlist, StationMedia $media)
{
$this->playlist = $playlist;
@ -72,49 +68,31 @@ class StationPlaylistMedia implements JsonSerializable
$this->last_played = 0;
}
/**
* @return int
*/
public function getId(): int
{
return $this->id;
}
/**
* @return StationPlaylist
*/
public function getPlaylist(): StationPlaylist
{
return $this->playlist;
}
/**
* @return StationMedia
*/
public function getMedia(): StationMedia
{
return $this->media;
}
/**
* @return int
*/
public function getWeight(): int
{
return $this->weight;
}
/**
* @param int $weight
*/
public function setWeight(int $weight): void
{
$this->weight = $weight;
}
/**
* @return int
*/
public function getLastPlayed(): int
{
return $this->last_played;

View File

@ -290,7 +290,7 @@ class StationRemote implements StationMountInterface
public function setCustomListenUrl(string $custom_listen_url = null): void
{
$this->custom_listen_url = $this->_truncateString($custom_listen_url, 255);
$this->custom_listen_url = $this->truncateString($custom_listen_url, 255);
}
/** @inheritdoc */
@ -306,7 +306,7 @@ class StationRemote implements StationMountInterface
public function setSourceUsername(?string $source_username): void
{
$this->source_username = $this->_truncateString($source_username, 100);
$this->source_username = $this->truncateString($source_username, 100);
}
/** @inheritdoc */
@ -335,7 +335,7 @@ class StationRemote implements StationMountInterface
public function setSourcePassword(?string $source_password): void
{
$this->source_password = $this->_truncateString($source_password, 100);
$this->source_password = $this->truncateString($source_password, 100);
}
public function getType(): string
@ -355,7 +355,7 @@ class StationRemote implements StationMountInterface
public function setSourceMount(?string $source_mount): void
{
$this->source_mount = $this->_truncateString($source_mount, 150);
$this->source_mount = $this->truncateString($source_mount, 150);
}
public function getMount(): ?string
@ -365,7 +365,7 @@ class StationRemote implements StationMountInterface
public function setMount(?string $mount): void
{
$this->mount = $this->_truncateString($mount, 150);
$this->mount = $this->truncateString($mount, 150);
}
public function getAdminPassword(): ?string
@ -410,7 +410,7 @@ class StationRemote implements StationMountInterface
$url = 'http://' . $url;
}
$this->url = $this->_truncateString($url);
$this->url = $this->truncateString($url);
}
/*
@ -537,6 +537,6 @@ class StationRemote implements StationMountInterface
*/
public function setDisplayName(?string $display_name): void
{
$this->display_name = $this->_truncateString($display_name);
$this->display_name = $this->truncateString($display_name);
}
}

View File

@ -100,57 +100,36 @@ class StationSchedule
}
}
/**
* @return int|null
*/
public function getId(): ?int
{
return $this->id;
}
/**
* @return StationPlaylist|null
*/
public function getPlaylist(): ?StationPlaylist
{
return $this->playlist;
}
/**
* @return StationStreamer|null
*/
public function getStreamer(): ?StationStreamer
{
return $this->streamer;
}
/**
* @return int
*/
public function getStartTime(): int
{
return (int)$this->start_time;
}
/**
* @param int $start_time
*/
public function setStartTime(int $start_time): void
{
$this->start_time = $start_time;
}
/**
* @return int
*/
public function getEndTime(): int
{
return (int)$this->end_time;
}
/**
* @param int $end_time
*/
public function setEndTime(int $end_time): void
{
$this->end_time = $end_time;
@ -173,49 +152,31 @@ class StationSchedule
return $end_time - $start_time;
}
/**
* @return string|null
*/
public function getStartDate(): ?string
{
return $this->start_date;
}
/**
* @param string|null $start_date
*/
public function setStartDate(?string $start_date): void
{
$this->start_date = $start_date;
}
/**
* @return string|null
*/
public function getEndDate(): ?string
{
return $this->end_date;
}
/**
* @param string|null $end_date
*/
public function setEndDate(?string $end_date): void
{
$this->end_date = $end_date;
}
/**
* @return array|null
*/
public function getDays(): ?array
{
return (!empty($this->days)) ? explode(',', $this->days) : null;
}
/**
* @param array $days
*/
public function setDays($days): void
{
$this->days = implode(',', (array)$days);

View File

@ -134,49 +134,31 @@ class StationStreamer
$this->schedule_items = new ArrayCollection;
}
/**
* @return int
*/
public function getId(): int
{
return $this->id;
}
/**
* @return Station
*/
public function getStation(): Station
{
return $this->station;
}
/**
* @return string
*/
public function getStreamerUsername(): string
{
return $this->streamer_username;
}
/**
* @param string $streamer_username
*/
public function setStreamerUsername(string $streamer_username): void
{
$this->streamer_username = $this->_truncateString($streamer_username, 50);
$this->streamer_username = $this->truncateString($streamer_username, 50);
}
/**
* @return string
*/
public function getStreamerPassword(): string
{
return '';
}
/**
* @param string|null $streamer_password
*/
public function setStreamerPassword(?string $streamer_password): void
{
$streamer_password = trim($streamer_password);
@ -193,7 +175,6 @@ class StationStreamer
/**
* @AuditLog\AuditIdentifier()
*
* @return string
*/
public function getDisplayName(): string
@ -203,41 +184,26 @@ class StationStreamer
: $this->streamer_username;
}
/**
* @param null|string $display_name
*/
public function setDisplayName(?string $display_name): void
{
$this->display_name = $this->_truncateString($display_name);
$this->display_name = $this->truncateString($display_name);
}
/**
* @return null|string
*/
public function getComments(): ?string
{
return $this->comments;
}
/**
* @param null|string $comments
*/
public function setComments(string $comments = null): void
{
$this->comments = $comments;
}
/**
* @return bool
*/
public function isActive(): bool
{
return $this->is_active;
}
/**
* @param bool $is_active
*/
public function setIsActive(bool $is_active): void
{
$this->is_active = $is_active;
@ -248,43 +214,26 @@ class StationStreamer
}
}
/**
* @return bool
*/
public function enforceSchedule(): bool
{
return $this->enforce_schedule;
}
/**
* @param bool $enforce_schedule
*/
public function setEnforceSchedule(bool $enforce_schedule): void
{
$this->enforce_schedule = $enforce_schedule;
}
/**
* @return int|null
*/
public function getReactivateAt(): ?int
{
return $this->reactivate_at;
}
/**
* @param int|null $reactivate_at
*/
public function setReactivateAt(?int $reactivate_at): void
{
$this->reactivate_at = $reactivate_at;
}
/**
* Deactivate this streamer for the specified period of time.
*
* @param int $seconds
*/
public function deactivateFor(int $seconds): void
{
$this->is_active = false;
@ -299,13 +248,6 @@ class StationStreamer
return $this->schedule_items;
}
/**
* Determine whether the given DJ is allowed to broadcast at the given moment.
*
* @param Chronos|null $now
*
* @return bool
*/
public function canStreamNow(Chronos $now = null): bool
{
if (!$this->enforceSchedule()) {

View File

@ -72,57 +72,36 @@ class StationStreamerBroadcast
$this->timestampStart = time();
}
/**
* @return int
*/
public function getId(): int
{
return $this->id;
}
/**
* @return Station
*/
public function getStation(): Station
{
return $this->station;
}
/**
* @return StationStreamer
*/
public function getStreamer(): StationStreamer
{
return $this->streamer;
}
/**
* @return int
*/
public function getTimestampStart(): int
{
return $this->timestampStart;
}
/**
* @return int
*/
public function getTimestampEnd(): int
{
return $this->timestampEnd;
}
/**
* @param int $timestampEnd
*/
public function setTimestampEnd(int $timestampEnd): void
{
$this->timestampEnd = $timestampEnd;
}
/**
* @return string|null
*/
public function getRecordingPath(): ?string
{
return $this->recordingPath;

View File

@ -106,17 +106,11 @@ class StationWebhook
$this->type = $type;
}
/**
* @return int|null
*/
public function getId(): ?int
{
return $this->id;
}
/**
* @return Station
*/
public function getStation(): Station
{
return $this->station;
@ -124,7 +118,6 @@ class StationWebhook
/**
* @AuditLog\AuditIdentifier
*
* @return null|string
*/
public function getName(): ?string
@ -132,75 +125,48 @@ class StationWebhook
return $this->name;
}
/**
* @param null|string $name
*/
public function setName(?string $name): void
{
$this->name = $this->_truncateString($name, 100);
$this->name = $this->truncateString($name, 100);
}
/**
* @return string
*/
public function getType(): string
{
return $this->type;
}
/**
* @return bool
*/
public function isEnabled(): bool
{
return $this->is_enabled;
}
/**
* @return bool
*/
public function toggleEnabled(): bool
{
$this->is_enabled = !$this->is_enabled;
return $this->is_enabled;
}
/**
* @param bool $is_enabled
*/
public function setIsEnabled(bool $is_enabled): void
{
$this->is_enabled = $is_enabled;
}
/**
* @return array
*/
public function getTriggers(): array
{
return (array)$this->triggers;
}
/**
* @param array|null $triggers
*/
public function setTriggers(array $triggers = null): void
public function setTriggers(?array $triggers = null): void
{
$this->triggers = $triggers;
}
/**
* @return array
*/
public function getConfig(): array
{
return (array)$this->config;
}
/**
* @param array|null $config
*/
public function setConfig(array $config = null): void
public function setConfig(?array $config = null): void
{
$this->config = $config;
}

View File

@ -11,7 +11,7 @@ trait TruncateStrings
*
* @return null|string
*/
protected function _truncateString(?string $string = null, $length = 255): ?string
protected function truncateString(?string $string = null, $length = 255): ?string
{
if ($string === null) {
return null;

View File

@ -3,8 +3,8 @@ namespace App\Entity;
use App\Annotations\AuditLog;
use App\Auth;
use App\Service\Gravatar;
use App\Normalizer\Annotation\DeepNormalize;
use App\Service\Gravatar;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
@ -158,9 +158,6 @@ class User
$this->updated_at = time();
}
/**
* @return int
*/
public function getId(): int
{
return $this->id;
@ -168,7 +165,6 @@ class User
/**
* @AuditLog\AuditIdentifier()
*
* @return string
*/
public function getIdentifier(): string
@ -176,47 +172,30 @@ class User
return $this->getName() . ' (' . $this->getEmail() . ')';
}
/**
* @return null|string
*/
public function getName(): ?string
{
return $this->name;
}
/**
* @param null|string $name
*/
public function setName($name): void
public function setName(?string $name = null): void
{
$this->name = $this->_truncateString($name, 100);
$this->name = $this->truncateString($name, 100);
}
/**
* @return null|string
*/
public function getEmail(): ?string
{
return $this->email;
}
/**
* @param null|string $email
*/
public function setEmail($email): void
public function setEmail(?string $email = null): void
{
$this->email = $this->_truncateString($email, 100);
$this->email = $this->truncateString($email, 100);
}
/**
* @param string $password
*
* @return bool
*/
public function verifyPassword($password): bool
public function verifyPassword(string $password): bool
{
if (password_verify($password, $this->auth_password)) {
[$algo, $algo_opts] = $this->_getPasswordAlgorithm();
[$algo, $algo_opts] = $this->getPasswordAlgorithm();
if (password_needs_rehash($this->auth_password, $algo, $algo_opts)) {
$this->setNewPassword($password);
@ -232,7 +211,7 @@ class User
*
* @return array [algorithm constant, algorithm options array]
*/
protected function _getPasswordAlgorithm(): array
protected function getPasswordAlgorithm(): array
{
if (defined('PASSWORD_ARGON2ID')) {
return [PASSWORD_ARGON2ID, []];
@ -241,13 +220,10 @@ class User
return [PASSWORD_BCRYPT, []];
}
/**
* @param string $password
*/
public function setNewPassword(string $password): void
{
if (trim($password)) {
[$algo, $algo_opts] = $this->_getPasswordAlgorithm();
[$algo, $algo_opts] = $this->getPasswordAlgorithm();
$this->auth_password = password_hash($password, $algo, $algo_opts);
}
}
@ -257,59 +233,36 @@ class User
$this->setNewPassword(bin2hex(random_bytes(20)));
}
/**
* @return null|string
*/
public function getLocale(): ?string
{
return $this->locale;
}
/**
* @param null|string $locale
*/
public function setLocale($locale): void
public function setLocale(?string $locale = null): void
{
$this->locale = $locale;
}
/**
* @return null|string
*/
public function getTheme(): ?string
{
return $this->theme;
}
/**
* @param null|string $theme
*/
public function setTheme($theme): void
public function setTheme(?string $theme = null): void
{
$this->theme = $theme;
}
/**
* @return string|null
*/
public function getTwoFactorSecret(): ?string
{
return $this->two_factor_secret;
}
/**
* @param string|null $two_factor_secret
*/
public function setTwoFactorSecret(?string $two_factor_secret): void
public function setTwoFactorSecret(?string $two_factor_secret = null): void
{
$this->two_factor_secret = $two_factor_secret;
}
/**
* @param string $otp
*
* @return bool
*/
public function verifyTwoFactor(string $otp): bool
{
if (null === $this->two_factor_secret) {
@ -320,24 +273,18 @@ class User
return $totp->verify($otp, null, Auth::TOTP_WINDOW);
}
/**
* @return int
*/
public function getCreatedAt(): int
{
return $this->created_at;
}
/**
* @return int
*/
public function getUpdatedAt(): int
{
return $this->updated_at;
}
/**
* @return Collection
* @return Collection|Role[]
*/
public function getRoles(): Collection
{
@ -345,19 +292,14 @@ class User
}
/**
* @return Collection
* @return Collection|ApiKey[]
*/
public function getApiKeys(): Collection
{
return $this->api_keys;
}
/**
* @param int $size
*
* @return string
*/
public function getAvatar($size = 50): string
public function getAvatar(int $size = 50): string
{
return Gravatar::get($this->email, $size, 'https://www.azuracast.com/img/avatar.png');
}