Make protected functions private where appropriate.

This commit is contained in:
Buster "Silver Eagle" Neece 2022-08-22 23:29:04 -05:00
parent 23ddccd49c
commit 16fca14476
No known key found for this signature in database
GPG Key ID: F1D2E64A0005E80E
41 changed files with 77 additions and 89 deletions

View File

@ -144,7 +144,7 @@ final class AppFactory
return new Environment($environment);
}
protected static function applyPhpSettings(Environment $environment): void
private static function applyPhpSettings(Environment $environment): void
{
error_reporting(
$environment->isProduction()

View File

@ -60,7 +60,7 @@ final class NowPlayingCommand extends AbstractSyncCommand
return 0;
}
protected function loop(SymfonyStyle $io, int $timeout): void
private function loop(SymfonyStyle $io, int $timeout): void
{
$threshold = time() + $timeout;
@ -98,7 +98,7 @@ final class NowPlayingCommand extends AbstractSyncCommand
}
}
protected function start(
private function start(
SymfonyStyle $io,
string $shortName
): void {

View File

@ -354,7 +354,7 @@ class StationsController extends AbstractAdminApiCrudController
// Create default mountpoints if station supports them.
$this->stationRepo->resetMounts($station);
} catch (\Throwable $e) {
} catch (Throwable $e) {
$this->em->remove($station);
$this->em->flush();

View File

@ -41,7 +41,7 @@ final class AuditLog implements EventSubscriber
public function onFlush(OnFlushEventArgs $args): void
{
$em = $args->getEntityManager();
$em = $args->getObjectManager();
$uow = $em->getUnitOfWork();
$singleAuditLogs = $this->handleSingleUpdates($em, $uow);
@ -58,7 +58,7 @@ final class AuditLog implements EventSubscriber
}
/** @return Entity\AuditLog[] */
protected function handleSingleUpdates(
private function handleSingleUpdates(
EntityManagerInterface $em,
UnitOfWork $uow
): array {
@ -129,7 +129,7 @@ final class AuditLog implements EventSubscriber
}
/** @return Entity\AuditLog[] */
protected function handleCollectionUpdates(
private function handleCollectionUpdates(
UnitOfWork $uow
): array {
$newRecords = [];
@ -240,7 +240,7 @@ final class AuditLog implements EventSubscriber
return $newRecords;
}
protected function isEntity(EntityManagerInterface $em, mixed $class): bool
private function isEntity(EntityManagerInterface $em, mixed $class): bool
{
if (is_object($class)) {
$class = ($class instanceof Proxy || $class instanceof GhostObjectInterface)
@ -264,7 +264,7 @@ final class AuditLog implements EventSubscriber
* @param ReflectionClass<TObject> $refl
* @return bool
*/
protected function isAuditable(ReflectionClass $refl): bool
private function isAuditable(ReflectionClass $refl): bool
{
$auditable = $refl->getAttributes(Auditable::class);
return !empty($auditable);
@ -275,7 +275,7 @@ final class AuditLog implements EventSubscriber
*
* @param object $entity
*/
protected function getIdentifier(object $entity): string
private function getIdentifier(object $entity): string
{
if ($entity instanceof Stringable) {
return (string)$entity;

View File

@ -29,7 +29,7 @@ final class StationRequiresRestart implements EventSubscriber
public function onFlush(OnFlushEventArgs $args): void
{
$em = $args->getEntityManager();
$em = $args->getObjectManager();
$uow = $em->getUnitOfWork();
$collections_to_check = [

View File

@ -11,6 +11,7 @@ use Exception;
use GuzzleHttp\Psr7\Uri;
use NowPlaying\Result\Result;
use Psr\Http\Message\UriInterface;
use RuntimeException;
final class NowPlayingApiGenerator
{
@ -69,7 +70,7 @@ final class NowPlayingApiGenerator
$currentSong = array_shift($history);
if (null === $currentSong) {
throw new \RuntimeException('No current song.');
throw new RuntimeException('No current song.');
}
} catch (Exception $e) {
Logger::getInstance()->error($e->getMessage(), ['exception' => $e]);

View File

@ -55,7 +55,7 @@ final class SongApiGenerator
return $response;
}
protected function getAlbumArtUrl(
private function getAlbumArtUrl(
Entity\Interfaces\SongInterface $song,
?Entity\Station $station = null,
bool $allowRemoteArt = false,
@ -104,7 +104,7 @@ final class SongApiGenerator
*
* @return mixed[]
*/
protected function getCustomFields(?int $media_id = null): array
private function getCustomFields(?int $media_id = null): array
{
$fields = $this->customFieldRepo->getFieldIds();

View File

@ -135,7 +135,7 @@ final class StationMediaRepository extends Repository
return $record;
}
protected function getStorageLocation(Entity\Station|Entity\StorageLocation $source): Entity\StorageLocation
private function getStorageLocation(Entity\Station|Entity\StorageLocation $source): Entity\StorageLocation
{
if ($source instanceof Entity\Station) {
return $source->getMediaStorageLocation();
@ -461,7 +461,7 @@ final class StationMediaRepository extends Repository
return $affectedPlaylists;
}
protected function getFilesystem(Entity\StationMedia $media): ExtendedFilesystemInterface
private function getFilesystem(Entity\StationMedia $media): ExtendedFilesystemInterface
{
return $media->getStorageLocation()->getFilesystem();
}

View File

@ -37,7 +37,7 @@ final class StationMountRepository extends AbstractStationBasedRepository
$this->em->flush();
}
protected function doDeleteIntro(
private function doDeleteIntro(
Entity\StationMount $mount,
?ExtendedFilesystemInterface $fs = null
): void {

View File

@ -303,7 +303,7 @@ final class StationPlaylistMediaRepository extends Repository
return $notQueuedMediaCount === $totalMediaCount;
}
protected function getCountPlaylistMediaBaseQuery(Entity\StationPlaylist $playlist): QueryBuilder
private function getCountPlaylistMediaBaseQuery(Entity\StationPlaylist $playlist): QueryBuilder
{
return $this->em->createQueryBuilder()
->select('count(spm.id)')

View File

@ -192,13 +192,7 @@ final class StationQueueRepository extends AbstractStationBasedRepository
return $cuedPlaylistContentCount > 0;
}
protected function getRecentBaseQuery(Entity\Station $station): QueryBuilder
{
return $this->getBaseQuery($station)
->orderBy('sq.timestamp_cued', 'DESC');
}
protected function getUnplayedBaseQuery(Entity\Station $station): QueryBuilder
private function getUnplayedBaseQuery(Entity\Station $station): QueryBuilder
{
return $this->getBaseQuery($station)
->andWhere('sq.is_played = 0')
@ -206,7 +200,7 @@ final class StationQueueRepository extends AbstractStationBasedRepository
->addOrderBy('sq.timestamp_cued', 'ASC');
}
protected function getBaseQuery(Entity\Station $station): QueryBuilder
private function getBaseQuery(Entity\Station $station): QueryBuilder
{
return $this->em->createQueryBuilder()
->select('sq, sm, sp')

View File

@ -353,7 +353,7 @@ class Station implements Stringable, IdentifiableEntityInterface
ORM\Column(nullable: true),
Attributes\AuditIgnore
]
protected ?int $current_streamer_id = null;
private ?int $current_streamer_id = null;
#[
ORM\ManyToOne,

View File

@ -11,7 +11,7 @@ use Throwable;
final class ValidationException extends Exception
{
protected ConstraintViolationListInterface $detailedErrors;
private ConstraintViolationListInterface $detailedErrors;
public function __construct(
string $message = 'Validation error.',

View File

@ -67,7 +67,7 @@ final class ErrorHandler extends \Slim\Handlers\ErrorHandler
return parent::__invoke($request, $exception, $displayErrorDetails, $logErrors, $logErrorDetails);
}
protected function shouldReturnJson(ServerRequestInterface $req): bool
private function shouldReturnJson(ServerRequestInterface $req): bool
{
$xhr = $req->getHeaderLine('X-Requested-With') === 'XMLHttpRequest';

View File

@ -278,7 +278,7 @@ final class InstallCommand extends Command
return 0;
}
protected function updateDockerCompose(
private function updateDockerCompose(
string $dockerComposePath,
AbstractEnvFile $env,
AbstractEnvFile $azuracastEnv

View File

@ -53,7 +53,7 @@ final class LastFmAlbumArtHandler extends AbstractAlbumArtHandler
return null;
}
protected function getImageFromArray(array $images): ?string
private function getImageFromArray(array $images): ?string
{
$imagesBySize = [];
foreach ($images as $image) {

View File

@ -50,7 +50,7 @@ final class QueueManager extends AbstractQueueManager
);
}
protected function getConnection(string $queueName): MessengerConnection
private function getConnection(string $queueName): MessengerConnection
{
return new MessengerConnection(
[

View File

@ -82,7 +82,7 @@ final class Adapters
* @param bool $checkInstalled
* @return mixed[]
*/
protected function listAdaptersFromEnum(array $cases, bool $checkInstalled = false): array
private function listAdaptersFromEnum(array $cases, bool $checkInstalled = false): array
{
$adapters = [];
foreach ($cases as $adapter) {

View File

@ -157,7 +157,7 @@ final class DuplicatePrevention
return null;
}
protected function getArtistParts(string $artists): array
private function getArtistParts(string $artists): array
{
$dividerString = chr(7);
@ -174,7 +174,7 @@ final class DuplicatePrevention
);
}
protected function prepareStringForMatching(string $string): string
private function prepareStringForMatching(string $string): string
{
return mb_strtolower(trim($string));
}

View File

@ -224,7 +224,7 @@ final class Queue
return $nextSongs;
}
protected function addDurationToTime(Entity\Station $station, CarbonInterface $now, ?int $duration): CarbonInterface
private function addDurationToTime(Entity\Station $station, CarbonInterface $now, ?int $duration): CarbonInterface
{
$duration ??= 1;
@ -252,7 +252,7 @@ final class Queue
);
}
protected function getQueueRowLogCacheKey(Entity\StationQueue $queueRow): string
private function getQueueRowLogCacheKey(Entity\StationQueue $queueRow): string
{
return 'queue_log.' . $queueRow->getIdRequired();
}

View File

@ -184,7 +184,7 @@ final class QueueBuilder implements EventSubscriberInterface
*
* @param array $original
*/
protected function weightedShuffle(array &$original): void
private function weightedShuffle(array &$original): void
{
$new = $original;
@ -218,7 +218,7 @@ final class QueueBuilder implements EventSubscriberInterface
* @param bool $allowDuplicates Whether to return a media ID even if duplicates can't be prevented.
* @return Entity\StationQueue|Entity\StationQueue[]|null
*/
protected function playSongFromPlaylist(
private function playSongFromPlaylist(
Entity\StationPlaylist $playlist,
array $recentSongHistory,
CarbonInterface $expectedPlayTime,
@ -282,7 +282,7 @@ final class QueueBuilder implements EventSubscriberInterface
return null;
}
protected function makeQueueFromApi(
private function makeQueueFromApi(
Entity\Api\StationPlaylistQueue $validTrack,
Entity\StationPlaylist $playlist,
CarbonInterface $expectedPlayTime,
@ -305,7 +305,7 @@ final class QueueBuilder implements EventSubscriberInterface
return $stationQueueEntry;
}
protected function getSongFromRemotePlaylist(
private function getSongFromRemotePlaylist(
Entity\StationPlaylist $playlist,
CarbonInterface $expectedPlayTime
): ?Entity\StationQueue {
@ -340,7 +340,7 @@ final class QueueBuilder implements EventSubscriberInterface
*
* @return mixed[]|null
*/
protected function getMediaFromRemoteUrl(Entity\StationPlaylist $playlist): ?array
private function getMediaFromRemoteUrl(Entity\StationPlaylist $playlist): ?array
{
$remoteType = $playlist->getRemoteTypeEnum() ?? Entity\Enums\PlaylistRemoteTypes::Stream;
@ -380,7 +380,7 @@ final class QueueBuilder implements EventSubscriberInterface
: null;
}
protected function getRandomMediaIdFromPlaylist(
private function getRandomMediaIdFromPlaylist(
Entity\StationPlaylist $playlist,
array $recentSongHistory,
bool $allowDuplicates
@ -394,7 +394,7 @@ final class QueueBuilder implements EventSubscriberInterface
return array_shift($mediaQueue);
}
protected function getSequentialMediaIdFromPlaylist(
private function getSequentialMediaIdFromPlaylist(
Entity\StationPlaylist $playlist
): ?Entity\Api\StationPlaylistQueue {
$mediaQueue = $this->spmRepo->getQueue($playlist);
@ -405,7 +405,7 @@ final class QueueBuilder implements EventSubscriberInterface
return array_shift($mediaQueue);
}
protected function getShuffledMediaIdFromPlaylist(
private function getShuffledMediaIdFromPlaylist(
Entity\StationPlaylist $playlist,
array $recentSongHistory,
bool $allowDuplicates

View File

@ -118,7 +118,7 @@ final class Scheduler
return null !== $scheduleItem;
}
protected function shouldPlaylistPlayNowPerHour(
private function shouldPlaylistPlayNowPerHour(
Entity\StationPlaylist $playlist,
CarbonInterface $now
): bool {
@ -140,7 +140,7 @@ final class Scheduler
return !$this->wasPlaylistPlayedInLastXMinutes($playlist, $now, 30);
}
protected function wasPlaylistPlayedInLastXMinutes(
private function wasPlaylistPlayedInLastXMinutes(
Entity\StationPlaylist $playlist,
CarbonInterface $now,
int $minutes
@ -154,7 +154,7 @@ final class Scheduler
return ($playedAt > $threshold);
}
protected function wasPlaylistPlayedRecently(
private function wasPlaylistPlayedRecently(
Entity\StationPlaylist $playlist,
array $recentPlaylistHistory = [],
int $length = 15
@ -232,7 +232,7 @@ final class Scheduler
* @param CarbonInterface $now
* @return Entity\StationSchedule|null
*/
protected function getActiveScheduleFromCollection(
private function getActiveScheduleFromCollection(
Collection $scheduleItems,
CarbonInterface $now
): ?Entity\StationSchedule {
@ -320,7 +320,7 @@ final class Scheduler
return false;
}
protected function shouldPlayInSchedulePeriod(
private function shouldPlayInSchedulePeriod(
Entity\StationSchedule $schedule,
DateRange $dateRange,
CarbonInterface $now
@ -360,7 +360,7 @@ final class Scheduler
return true;
}
protected function shouldPlaylistLoopNow(
private function shouldPlaylistLoopNow(
Entity\StationSchedule $schedule,
DateRange $dateRange,
CarbonInterface $now,

View File

@ -1178,7 +1178,7 @@ final class ConfigWriter implements EventSubscriberInterface
/**
* Given outbound broadcast information, produce a suitable LiquidSoap configuration line for the stream.
*/
protected function getOutputString(
private function getOutputString(
Entity\Station $station,
Entity\Interfaces\StationMountInterface $mount,
string $idPrefix,
@ -1246,7 +1246,7 @@ final class ConfigWriter implements EventSubscriberInterface
return 'output.icecast(' . implode(', ', $output_params) . ')';
}
protected function getOutputFormatString(StreamFormats $format, int $bitrate = 128): string
private function getOutputFormatString(StreamFormats $format, int $bitrate = 128): string
{
switch ($format) {
case StreamFormats::Aac:

View File

@ -101,7 +101,7 @@ final class PlaylistFileWriter implements EventSubscriberInterface
}
}
protected function writePlaylistFile(Entity\StationPlaylist $playlist): void
private function writePlaylistFile(Entity\StationPlaylist $playlist): void
{
$station = $playlist->getStation();

View File

@ -62,7 +62,7 @@ final class BlocklistParser
return $this->isIpInList($ip, $bannedIps);
}
protected function isIpInList(
private function isIpInList(
string $listenerIp,
string $ipList
): bool {
@ -107,15 +107,8 @@ final class BlocklistParser
$listenerLocation = $this->ipGeolocation->getLocationInfo($listenerIp);
if (null !== $listenerLocation->country) {
foreach ($bannedCountries as $countryCode) {
if ($countryCode === $listenerLocation->country) {
return true;
}
}
}
return false;
return (null !== $listenerLocation->country)
&& in_array($listenerLocation->country, $bannedCountries, true);
}
public function isUserAgentBanned(

View File

@ -142,7 +142,7 @@ final class Flow
return $response->withStatus(200, 'OK');
}
protected static function handleStandardUpload(
private static function handleStandardUpload(
ServerRequest $request,
string $tempDir
): UploadedFile {
@ -171,7 +171,7 @@ final class Flow
* @param int $targetSize
* @param int $targetChunkNumber
*/
protected static function allPartsExist(
private static function allPartsExist(
string $chunkBaseDir,
int $targetSize,
int $targetChunkNumber
@ -187,7 +187,7 @@ final class Flow
return ($chunkSize === $targetSize && $chunkNumber === $targetChunkNumber);
}
protected static function createFileFromChunks(
private static function createFileFromChunks(
string $tempDir,
string $chunkBaseDir,
string $chunkIdentifier,

View File

@ -99,7 +99,7 @@ final class LastFm
return $responseJson;
}
protected function createExceptionFromErrorCode(int $errorCode): RuntimeException
private function createExceptionFromErrorCode(int $errorCode): RuntimeException
{
$errorDescriptions = [
2 => 'Invalid service - This service does not exist',

View File

@ -134,7 +134,7 @@ final class MusicBrainz
return $response['recordings'];
}
protected function quoteQuery(string $query): string
private function quoteQuery(string $query): string
{
return '"' . str_replace('"', '\'', $query) . '"';
}

View File

@ -85,7 +85,7 @@ final class Csrf
*
* @return string The randomly generated string.
*/
protected function randomString(int $length = self::CODE_LENGTH): string
private function randomString(int $length = self::CODE_LENGTH): string
{
$seed = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijqlmnopqrtsuvwxyz0123456789';
$max = strlen($seed) - 1;
@ -98,7 +98,7 @@ final class Csrf
return $string;
}
protected function getSessionIdentifier(string $namespace): string
private function getSessionIdentifier(string $namespace): string
{
return 'csrf_' . $namespace;
}

View File

@ -164,7 +164,7 @@ final class NowPlayingTask implements NowPlayingTaskInterface, EventSubscriberIn
}
}
protected function dispatchWebhooks(
private function dispatchWebhooks(
Entity\Station $station,
NowPlaying $npOriginal
): void {

View File

@ -80,7 +80,7 @@ final class CheckFolderPlaylistsTask extends AbstractTask
}
}
protected function processPlaylist(
private function processPlaylist(
Entity\Station $station,
Entity\StationPlaylist $playlist,
ExtendedFilesystemInterface $fsMedia,

View File

@ -173,7 +173,7 @@ final class CheckMediaTask extends AbstractTask
$this->logger->debug(sprintf('Media processed for "%s".', $storageLocation), $stats);
}
protected function processExistingMediaRows(
private function processExistingMediaRows(
Entity\StorageLocation $storageLocation,
array $queuedMediaUpdates,
array &$musicFiles,
@ -230,7 +230,7 @@ final class CheckMediaTask extends AbstractTask
$this->em->clear();
}
protected function processUnprocessableMediaRows(
private function processUnprocessableMediaRows(
Entity\StorageLocation $storageLocation,
array &$musicFiles,
array &$stats
@ -273,7 +273,7 @@ final class CheckMediaTask extends AbstractTask
$this->em->clear();
}
protected function processNewFiles(
private function processNewFiles(
Entity\StorageLocation $storageLocation,
array $queuedNewFiles,
array $musicFiles,

View File

@ -51,7 +51,7 @@ final class CheckRequestsTask extends AbstractTask
}
}
protected function submitRequest(Entity\Station $station, Entity\StationRequest $request): bool
private function submitRequest(Entity\Station $station, Entity\StationRequest $request): bool
{
// Send request to the station to play the request.
$backend = $this->adapters->getBackendAdapter($station);

View File

@ -43,7 +43,7 @@ final class CleanupStorageTask extends AbstractTask
}
}
protected function cleanStationTempFiles(Entity\Station $station): void
private function cleanStationTempFiles(Entity\Station $station): void
{
$tempDir = $station->getRadioTempDir();
$finder = new Finder();
@ -61,7 +61,7 @@ final class CleanupStorageTask extends AbstractTask
}
}
protected function cleanMediaStorageLocation(Entity\StorageLocation $storageLocation): void
private function cleanMediaStorageLocation(Entity\StorageLocation $storageLocation): void
{
$fs = $storageLocation->getFilesystem();

View File

@ -44,7 +44,7 @@ final class MoveBroadcastsTask extends AbstractTask
}
}
protected function processForStorageLocation(Entity\StorageLocation $storageLocation): void
private function processForStorageLocation(Entity\StorageLocation $storageLocation): void
{
if ($storageLocation->isStorageFull()) {
$this->logger->error('Storage location is full; skipping broadcasts.', [

View File

@ -58,7 +58,7 @@ final class QueueInterruptingTracks extends AbstractTask
}
}
protected function queueForStation(Entity\Station $station): void
private function queueForStation(Entity\Station $station): void
{
if (!$station->supportsAutoDjQueue()) {
return;

View File

@ -51,7 +51,7 @@ final class RunAnalyticsTask extends AbstractTask
}
}
protected function updateAnalytics(bool $withListeners): void
private function updateAnalytics(bool $withListeners): void
{
$stationsRaw = $this->em->getRepository(Entity\Station::class)
->findAll();
@ -84,7 +84,7 @@ final class RunAnalyticsTask extends AbstractTask
* @param Entity\Station[] $stations
* @param bool $withListeners
*/
protected function processDay(
private function processDay(
CarbonImmutable $day,
array $stations,
bool $withListeners
@ -249,12 +249,12 @@ final class RunAnalyticsTask extends AbstractTask
$this->em->persist($dailyAllStationsRow);
}
protected function purgeAnalytics(): void
private function purgeAnalytics(): void
{
$this->analyticsRepo->clearAll();
}
protected function purgeListeners(): void
private function purgeListeners(): void
{
$this->listenerRepo->clearAll();
}

View File

@ -42,7 +42,7 @@ final class UpdateStorageLocationSizesTask extends AbstractTask
}
}
protected function updateStorageLocationSize(Entity\StorageLocation $storageLocation): void
private function updateStorageLocationSize(Entity\StorageLocation $storageLocation): void
{
$fs = $storageLocation->getFilesystem();

View File

@ -209,7 +209,7 @@ final class View extends Engine
return $this->writeStringToResponse($response, $body);
}
protected function writeStringToResponse(
private function writeStringToResponse(
ResponseInterface $response,
string $body
): ResponseInterface {

View File

@ -157,7 +157,7 @@ final class Discord extends AbstractConnector
}
/** @noinspection HttpUrlsUsage */
protected function getImageUrl(?string $url = null): ?string
private function getImageUrl(?string $url = null): ?string
{
$url = $this->getValidUrl($url);
if (null !== $url) {

View File

@ -130,7 +130,7 @@ final class MatomoAnalytics extends AbstractConnector
return $this->sendBatch($apiUrl, $apiToken, $entries);
}
protected function sendBatch(UriInterface $apiUrl, ?string $apiToken, array $entries): bool
private function sendBatch(UriInterface $apiUrl, ?string $apiToken, array $entries): bool
{
if (empty($entries)) {
return true;