Skip to content

Commit

Permalink
PHPCsFixer
Browse files Browse the repository at this point in the history
  • Loading branch information
Yurujai committed Jan 17, 2024
1 parent 17dd3bd commit b3cbf07
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 17 deletions.
5 changes: 3 additions & 2 deletions Command/VideoUpdateStatusCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use MongoDB\BSON\ObjectId;
use Psr\Log\LoggerInterface;
use Pumukit\SchemaBundle\Document\MultimediaObject;
use Pumukit\YoutubeBundle\Document\Error;
use Pumukit\YoutubeBundle\Document\Youtube;
use Pumukit\YoutubeBundle\Services\VideoListService;
use Symfony\Component\Console\Command\Command;
Expand Down Expand Up @@ -81,7 +82,7 @@ protected function updateVideoStatusInYoutube($youtubeDocuments, OutputInterface
if (!$youtube->getYoutubeId()) {
$errorLog = sprintf('YouTube document %s does not have a Youtube ID variable set.', $youtube->getId());
$youtube->setStatus(Youtube::STATUS_ERROR);
$error = \Pumukit\YoutubeBundle\Document\Error::create(
$error = Error::create(
'pumukit.youtubeIdNotFound',
$errorLog,
new \DateTime(),
Expand All @@ -98,7 +99,7 @@ protected function updateVideoStatusInYoutube($youtubeDocuments, OutputInterface
if (!$multimediaObject instanceof MultimediaObject) {
$errorLog = sprintf("No multimedia object for YouTube document %s\n", $youtube->getId());
$youtube->setStatus(Youtube::STATUS_ERROR);
$error = \Pumukit\YoutubeBundle\Document\Error::create(
$error = Error::create(
'pumukit.videoNotFound',
$errorLog,
new \DateTime(),
Expand Down
3 changes: 2 additions & 1 deletion Services/CaptionsDeleteService.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use Doctrine\ODM\MongoDB\DocumentManager;
use Psr\Log\LoggerInterface;
use Pumukit\SchemaBundle\Document\Tag;
use Pumukit\YoutubeBundle\Document\Error;
use Pumukit\YoutubeBundle\Document\Youtube;

class CaptionsDeleteService extends GoogleCaptionService
Expand Down Expand Up @@ -35,7 +36,7 @@ public function deleteCaption(Tag $account, Youtube $youtube, array $captionsId)
$errorLog = sprintf('[YouTube] Remove caption for Youtube document %s failed. Error: %s', $youtube->getId(), $exception->getMessage());
$this->logger->error($errorLog);
$error = json_decode($exception->getMessage(), true, 512, JSON_THROW_ON_ERROR);
$error = \Pumukit\YoutubeBundle\Document\Error::create(
$error = Error::create(
$error['error']['errors'][0]['reason'],
$error['error']['errors'][0]['message'],
new \DateTime(),
Expand Down
3 changes: 2 additions & 1 deletion Services/CaptionsInsertService.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Pumukit\SchemaBundle\Document\MultimediaObject;
use Pumukit\SchemaBundle\Document\Tag;
use Pumukit\YoutubeBundle\Document\Caption;
use Pumukit\YoutubeBundle\Document\Error;
use Pumukit\YoutubeBundle\Document\Youtube;

class CaptionsInsertService extends GoogleCaptionService
Expand Down Expand Up @@ -56,7 +57,7 @@ public function uploadCaption(Youtube $youtube, MultimediaObject $multimediaObje
$youtube->removeCaptionUpdateError();
} catch (\Exception $exception) {
$error = json_decode($exception->getMessage(), true, 512, JSON_THROW_ON_ERROR);
$error = \Pumukit\YoutubeBundle\Document\Error::create(
$error = Error::create(
$error['error']['errors'][0]['reason'],
$error['error']['errors'][0]['message'],
new \DateTime(),
Expand Down
5 changes: 3 additions & 2 deletions Services/CaptionsListService.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,17 @@

namespace Pumukit\YoutubeBundle\Services;

use Google\Service\YouTube\CaptionListResponse;
use Pumukit\SchemaBundle\Document\Tag;

class CaptionsListService extends GoogleAccountService
{
public function findAll(Tag $account, string $videoId): \Google\Service\YouTube\CaptionListResponse
public function findAll(Tag $account, string $videoId): CaptionListResponse
{
return $this->list($account, $videoId);
}

private function list(Tag $account, string $videoId): \Google\Service\YouTube\CaptionListResponse
private function list(Tag $account, string $videoId): CaptionListResponse
{
$service = $this->googleServiceFromAccount($account);

Expand Down
5 changes: 3 additions & 2 deletions Services/PlaylistItemInsertService.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Psr\Log\LoggerInterface;
use Pumukit\SchemaBundle\Document\MultimediaObject;
use Pumukit\SchemaBundle\Document\Tag;
use Pumukit\YoutubeBundle\Document\Error;
use Pumukit\YoutubeBundle\Document\Youtube;
use Pumukit\YoutubeBundle\PumukitYoutubeBundle;

Expand Down Expand Up @@ -105,7 +106,7 @@ private function fixPlaylistsForMultimediaObject(MultimediaObject $multimediaObj
$response = $this->playlistItemDeleteService->deleteOnePlaylist($account, $playlistRel);
} catch (\Exception $exception) {
$error = json_decode($exception->getMessage(), true, 512, JSON_THROW_ON_ERROR);
$error = \Pumukit\YoutubeBundle\Document\Error::create(
$error = Error::create(
$error['error']['errors'][0]['reason'],
$error['error']['errors'][0]['message'],
new \DateTime(),
Expand All @@ -132,7 +133,7 @@ private function fixPlaylistsForMultimediaObject(MultimediaObject $multimediaObj
$youtubeDocument->removePlaylistUpdateError();
} catch (\Exception $exception) {
$error = json_decode($exception->getMessage(), true, 512, JSON_THROW_ON_ERROR);
$error = \Pumukit\YoutubeBundle\Document\Error::create(
$error = Error::create(
$error['error']['errors'][0]['reason'],
$error['error']['errors'][0]['message'],
new \DateTime(),
Expand Down
9 changes: 5 additions & 4 deletions Services/VideoDeleteService.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Psr\Log\LoggerInterface;
use Pumukit\SchemaBundle\Document\MultimediaObject;
use Pumukit\SchemaBundle\Document\Tag;
use Pumukit\YoutubeBundle\Document\Error;
use Pumukit\YoutubeBundle\Document\Youtube;

class VideoDeleteService extends GoogleVideoService
Expand Down Expand Up @@ -67,7 +68,7 @@ public function deleteVideoFromYouTubeByMultimediaObject(MultimediaObject $multi
}
$response = $this->delete($account, $video);
if (204 !== $response->getStatusCode()) {
$error = \Pumukit\YoutubeBundle\Document\Error::create(
$error = Error::create(
$response->getReasonPhrase(),
$response->getReasonPhrase(),
new \DateTime(),
Expand All @@ -80,7 +81,7 @@ public function deleteVideoFromYouTubeByMultimediaObject(MultimediaObject $multi
}
} catch (\Exception $exception) {
$error = json_decode($exception->getMessage(), true, 512, JSON_THROW_ON_ERROR);
$error = \Pumukit\YoutubeBundle\Document\Error::create(
$error = Error::create(
$error['error']['errors'][0]['reason'],
$error['error']['errors'][0]['message'],
new \DateTime(),
Expand Down Expand Up @@ -120,7 +121,7 @@ public function deleteVideoFromYouTubeByYouTubeDocument(Youtube $youtube): bool
}
$response = $this->delete($account, $video);
if (204 !== $response->getStatusCode()) {
$error = \Pumukit\YoutubeBundle\Document\Error::create(
$error = Error::create(
$response->getReasonPhrase(),
$response->getReasonPhrase(),
new \DateTime(),
Expand All @@ -134,7 +135,7 @@ public function deleteVideoFromYouTubeByYouTubeDocument(Youtube $youtube): bool
}
} catch (\Exception $exception) {
$error = json_decode($exception->getMessage(), true, 512, JSON_THROW_ON_ERROR);
$error = \Pumukit\YoutubeBundle\Document\Error::create(
$error = Error::create(
$error['error']['errors'][0]['reason'],
$error['error']['errors'][0]['message'],
new \DateTime(),
Expand Down
3 changes: 2 additions & 1 deletion Services/VideoInsertService.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Pumukit\SchemaBundle\Document\MultimediaObject;
use Pumukit\SchemaBundle\Document\Tag;
use Pumukit\SchemaBundle\Document\Track;
use Pumukit\YoutubeBundle\Document\Error;
use Pumukit\YoutubeBundle\Document\Youtube;

class VideoInsertService extends GoogleVideoService
Expand Down Expand Up @@ -174,7 +175,7 @@ private function updateVideoAndYoutubeDocumentByErrorResult(
array $exception
): void {
$youtube->setStatus(Youtube::STATUS_ERROR);
$error = \Pumukit\YoutubeBundle\Document\Error::create(
$error = Error::create(
$exception['error']['errors'][0]['reason'],
$exception['error']['message'],
new \DateTime(),
Expand Down
5 changes: 3 additions & 2 deletions Services/VideoListService.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Psr\Log\LoggerInterface;
use Pumukit\SchemaBundle\Document\MultimediaObject;
use Pumukit\SchemaBundle\Document\Tag;
use Pumukit\YoutubeBundle\Document\Error;
use Pumukit\YoutubeBundle\Document\Youtube;

class VideoListService extends GoogleVideoService
Expand Down Expand Up @@ -65,7 +66,7 @@ public function updateVideoStatus(Youtube $youtube, MultimediaObject $multimedia
$status = $this->getStatusFromYouTubeResponse($response, $video);
} catch (\Exception $exception) {
$error = json_decode($exception->getMessage(), true, 512, JSON_THROW_ON_ERROR);
$error = \Pumukit\YoutubeBundle\Document\Error::create(
$error = Error::create(
$error['error']['errors'][0]['reason'],
$error['error']['errors'][0]['message'],
new \DateTime(),
Expand All @@ -81,7 +82,7 @@ public function updateVideoStatus(Youtube $youtube, MultimediaObject $multimedia
$youtube->setStatus($status);
if (Youtube::STATUS_ERROR === $status || Youtube::STATUS_TO_REVIEW === $status) {
$reason = $this->getReasonStatusFromYoutubeResponse($response, $video);
$error = \Pumukit\YoutubeBundle\Document\Error::create(
$error = Error::create(
'pumukit.statusError',
$reason,
new \DateTime(),
Expand Down
6 changes: 4 additions & 2 deletions Services/VideoUpdateService.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,11 @@
namespace Pumukit\YoutubeBundle\Services;

use Doctrine\ODM\MongoDB\DocumentManager;
use Google\Service\YouTube\Video;
use Psr\Log\LoggerInterface;
use Pumukit\SchemaBundle\Document\MultimediaObject;
use Pumukit\SchemaBundle\Document\Tag;
use Pumukit\YoutubeBundle\Document\Error;
use Pumukit\YoutubeBundle\Document\Youtube;

class VideoUpdateService extends GoogleVideoService
Expand Down Expand Up @@ -68,7 +70,7 @@ public function updateVideoOnYoutube(MultimediaObject $multimediaObject): bool
$response = $this->update($account, $video);
} catch (\Exception $exception) {
$error = json_decode($exception->getMessage(), true, 512, JSON_THROW_ON_ERROR);
$error = \Pumukit\YoutubeBundle\Document\Error::create(
$error = Error::create(
$error['error']['errors'][0]['reason'],
$error['error']['errors'][0]['message'],
new \DateTime(),
Expand All @@ -92,7 +94,7 @@ public function updateVideoOnYoutube(MultimediaObject $multimediaObject): bool
private function update(
Tag $youtubeAccount,
\Google_Service_YouTube_Video $video,
): \Google\Service\YouTube\Video {
): Video {
$infoLog = sprintf('[YouTube] Video update: %s ', $video->getId());
$this->logger->info($infoLog);

Expand Down

0 comments on commit b3cbf07

Please sign in to comment.