Skip to content

Commit

Permalink
Merge pull request #328 from bendesilva/add-vimeo
Browse files Browse the repository at this point in the history
Add Vimeo as a provider
  • Loading branch information
oscarotero authored Sep 16, 2019
2 parents 960bbd5 + 55df81e commit dc1dc3c
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/Adapters/Vimeo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php

namespace Embed\Adapters;

use Embed\Http\Response;

/**
* Adapter to provide information from Vimeo.
* Required when Vimeo returns a 403 status code.
*/
class Vimeo extends Webpage
{
/**
* {@inheritdoc}
*/
public static function check(Response $response)
{
return $response->isValid([200, 403]) && $response->getUrl()->match([
'vimeo.com/*',
]);
}
}
9 changes: 9 additions & 0 deletions src/Providers/OEmbed/Vimeo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?php

namespace Embed\Providers\OEmbed;

class Vimeo extends EndPoint implements EndPointInterface
{
protected static $pattern = ['vimeo.com/*'];
protected static $endPoint = 'https://vimeo.com/api/oembed.json';
}
20 changes: 20 additions & 0 deletions tests/VimeoTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
<?php

namespace Embed\Tests;

class VimeoTest extends AbstractTestCase
{
public function testOne()
{
$this->assertEmbed(
'https://vimeo.com/235352744',
[
'title' => 'Vimeo Live is here',
'providerName' => 'Vimeo',
'width' => 640,
'height' => 360,
'code' => '<iframe src="https://player.vimeo.com/video/235352744?app_id=122963" width="640" height="360" frameborder="0" allow="autoplay; fullscreen" allowfullscreen title="Vimeo Live is here"></iframe>',
]
);
}
}

0 comments on commit dc1dc3c

Please sign in to comment.