Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- namespace Services\Podcasting;
- use Services\Podcasting\Transcoder\Queue as TranscoderQueue;
- use Illuminate\Support\Carbon;
- use Illuminate\Contracts\Support\Jsonable;
- class PodcastStatus implements Jsonable
- {
- /**
- * Transcode Queue for Podcasts
- *
- * @var \Services\Podcasting\Transcoder\Queue
- */
- protected $queue;
- /**
- * The Podcast being checked
- *
- * @var App\Podcast
- */
- protected $podcast;
- /**
- * The Status of the Podcast
- *
- * @var string
- */
- protected $status;
- /**
- * If the Status is "pending" or "queued", the moment it may be start processing
- *
- * @var \Illuminate\Support\Carbon
- */
- protected $estimated_at;
- /**
- * Creates a new Podcasting instance
- *
- * @return void
- */
- public function __construct(TranscoderQueue $queue)
- {
- $this->queue = $queue;
- }
- /**
- * Get the processing status of a queued Podcast
- *
- * @return $this
- */
- public function getPodcastStatus(Podcast $podcast)
- {
- $this->podcast = $podcast;
- [$status, $estimated_at] = $this->queue->checkId($podcast->getKey());
- $this->status = $status;
- $this->estimated_at = $estimated_at ? Carbon::parse($estimated_at) : null;
- return $this;
- }
- /**
- * Convert the object to its JSON representation.
- *
- * @param int $options
- * @return string
- */
- public function toJson($options = 0)
- {
- return json_encode([
- 'podcast_id' => $this->podcast->getKey(),
- 'status' => $this->status ?? 'not_found',
- 'estimated_at' => $this->estimated_at,
- ]);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement