Skip to content

VideoService

Pieter Hordijk edited this page Jan 1, 2019 · 1 revision

TOC

VideoId

Validates the input (string) to be a valid YouTube video id.

Version information

Available since: 1.0.0

Usage

<?php declare(strict_types);

use Amp\Artax\DefaultClient;
use Amp\Redis\Client;
use HarmonyIO\Cache\Provider\Redis;
use HarmonyIO\HttpClient\Client\ArtaxClient;
use HarmonyIO\Validation\Rule\VideoService\YouTube\VideoId;

$httpClient = new ArtaxClient(new DefaultClient(), new Redis(new Client('tcp://127.0.0.1:6379')));

(new VideoId($httpClient))->validate('kfVsfOSbJY0');

Note: the results are cached for 1 hour.

Failure reasons

  • Type.String when the validated value is not a string
  • VideoService.YouTube.VideoId when the validated value is not a valid YouTube video id

VideoUrl

Validates the input (string) to be a valid YouTube video URL.

Version information

Available since: 1.0.0

Usage

<?php declare(strict_types);

use Amp\Artax\DefaultClient;
use Amp\Redis\Client;
use HarmonyIO\Cache\Provider\Redis;
use HarmonyIO\HttpClient\Client\ArtaxClient;
use HarmonyIO\Validation\Rule\VideoService\YouTube\VideoUrl;

$httpClient = new ArtaxClient(new DefaultClient(), new Redis(new Client('tcp://127.0.0.1:6379')));

(new VideoUrl($httpClient))->validate('https://www.youtube.com/watch?v=kfVsfOSbJY0');

Note: the results are cached for 1 hour.

Failure reasons

  • Type.String when the validated value is not a string
  • VideoService.YouTube.VideoUrl when the validated value is not a valid YouTube video URL
Clone this wiki locally