Format code using php-cs-fixer

This commit is contained in:
jo 2021-10-11 16:10:47 +02:00
parent 43d7dc92cd
commit d52c6184b9
352 changed files with 17473 additions and 17041 deletions

View file

@ -1,15 +1,17 @@
<?php
/**
* Class ServiceNotFoundException
* Class ServiceNotFoundException.
*/
class ServiceNotFoundException extends Exception {}
class ServiceNotFoundException extends Exception
{
}
/**
* Class ThirdPartyService generic superclass for third-party services
* Class ThirdPartyService generic superclass for third-party services.
*/
abstract class Application_Service_ThirdPartyService {
abstract class Application_Service_ThirdPartyService
{
/**
* @var string service name to store in ThirdPartyTrackReferences database
*/
@ -22,60 +24,68 @@ abstract class Application_Service_ThirdPartyService {
*
* @param $fileId int local CcFiles identifier
*
* @return string the new ThirdPartyTrackReferences identifier
*
* @throws Exception
* @throws PropelException
*
* @return string the new ThirdPartyTrackReferences identifier
*/
public function createTrackReference($fileId) {
public function createTrackReference($fileId)
{
// First, check if the track already has an entry in the database
// If the file ID given is null, create a new reference
$ref = is_null($fileId) ? null : ThirdPartyTrackReferencesQuery::create()
->filterByDbService(static::$_SERVICE_NAME)
->findOneByDbFileId($fileId);
->findOneByDbFileId($fileId)
;
if (is_null($ref)) {
$ref = new ThirdPartyTrackReferences();
}
$ref->setDbService(static::$_SERVICE_NAME);
$ref->setDbFileId($fileId);
$ref->save();
return $ref->getDbId();
}
/**
* Remove a ThirdPartyTrackReferences row from the database.
* This is necessary if the track was removed from the service
* or the foreign id in our database is incorrect
* or the foreign id in our database is incorrect.
*
* @param $fileId int cc_files identifier
*
* @throws Exception
* @throws PropelException
*/
public function removeTrackReference($fileId) {
public function removeTrackReference($fileId)
{
$ref = ThirdPartyTrackReferencesQuery::create()
->filterByDbService(static::$_SERVICE_NAME)
->findOneByDbFileId($fileId);
->findOneByDbFileId($fileId)
;
$ref->delete();
}
/**
* Given a CcFiles identifier for a file that's been uploaded to a third-party service,
* return the third-party identifier for the remote file
* return the third-party identifier for the remote file.
*
* @param int $fileId the cc_files identifier
*
* @return string the service foreign identifier
*/
public function getServiceId($fileId) {
public function getServiceId($fileId)
{
$ref = ThirdPartyTrackReferencesQuery::create()
->filterByDbService(static::$_SERVICE_NAME)
->findOneByDbFileId($fileId); // There shouldn't be duplicates!
->findOneByDbFileId($fileId) // There shouldn't be duplicates!
;
return empty($ref) ? '' : $ref->getDbForeignId();
}
/**
* Check if a reference exists for a given CcFiles identifier
* Check if a reference exists for a given CcFiles identifier.
*
* @param int $fileId the cc_files identifier
*
@ -83,18 +93,22 @@ abstract class Application_Service_ThirdPartyService {
* 0 if the file has yet to be published,
* or -1 if the file is in a pending state
*/
public function referenceExists($fileId) {
public function referenceExists($fileId)
{
$ref = ThirdPartyTrackReferencesQuery::create()
->filterByDbService(static::$_SERVICE_NAME)
->findOneByDbFileId($fileId);
->findOneByDbFileId($fileId)
;
if (!empty($ref)) {
$task = CeleryTasksQuery::create()
->orderByDbDispatchTime(Criteria::DESC)
->findOneByDbTrackReference($ref->getDbId());
->findOneByDbTrackReference($ref->getDbId())
;
return $task->getDbStatus() == CELERY_PENDING_STATUS ? -1
: ($task->getDbStatus() == CELERY_FAILED_STATUS ? 0 : 1);
}
return 0;
}
}
}