Skip to content

Commit dc1dc3c

Browse files
authored
Merge pull request #328 from bendesilva/add-vimeo
Add Vimeo as a provider
2 parents 960bbd5 + 55df81e commit dc1dc3c

File tree

3 files changed

+51
-0
lines changed

3 files changed

+51
-0
lines changed

src/Adapters/Vimeo.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<?php
2+
3+
namespace Embed\Adapters;
4+
5+
use Embed\Http\Response;
6+
7+
/**
8+
* Adapter to provide information from Vimeo.
9+
* Required when Vimeo returns a 403 status code.
10+
*/
11+
class Vimeo extends Webpage
12+
{
13+
/**
14+
* {@inheritdoc}
15+
*/
16+
public static function check(Response $response)
17+
{
18+
return $response->isValid([200, 403]) && $response->getUrl()->match([
19+
'vimeo.com/*',
20+
]);
21+
}
22+
}

src/Providers/OEmbed/Vimeo.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
<?php
2+
3+
namespace Embed\Providers\OEmbed;
4+
5+
class Vimeo extends EndPoint implements EndPointInterface
6+
{
7+
protected static $pattern = ['vimeo.com/*'];
8+
protected static $endPoint = 'https://vimeo.com/api/oembed.json';
9+
}

tests/VimeoTest.php

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?php
2+
3+
namespace Embed\Tests;
4+
5+
class VimeoTest extends AbstractTestCase
6+
{
7+
public function testOne()
8+
{
9+
$this->assertEmbed(
10+
'https://vimeo.com/235352744',
11+
[
12+
'title' => 'Vimeo Live is here',
13+
'providerName' => 'Vimeo',
14+
'width' => 640,
15+
'height' => 360,
16+
'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>',
17+
]
18+
);
19+
}
20+
}

0 commit comments

Comments
 (0)