Skip to content

Commit

Permalink
added Pinterest adapter #238
Browse files Browse the repository at this point in the history
  • Loading branch information
oscarotero committed Jul 19, 2017
1 parent 9709e2c commit b211d2d
Show file tree
Hide file tree
Showing 2 changed files with 68 additions and 0 deletions.
48 changes: 48 additions & 0 deletions src/Adapters/Pinterest.php
@@ -0,0 +1,48 @@
<?php

namespace Embed\Adapters;

use Embed\Http\Response;

/**
* Adapter to get embed code from pinterest.com.
*/
class Pinterest extends Webpage
{
/**
* {@inheritdoc}
*/
public static function check(Response $response)
{
return $response->isValid() && $response->getUrl()->match([
'www.pinterest.com/pin/*',
]);
}

/**
* {@inheritdoc}
*/
public function getCode()
{
return '<a data-pin-do="embedPin" data-pin-lang="es" href="'
.$this->getResponse()->getUrl()
.'"></a>'
.'<script async defer src="//assets.pinterest.com/js/pinit.js"></script>';
}

/**
* {@inheritdoc}
*/
public function getWidth()
{
return 236;
}

/**
* {@inheritdoc}
*/
public function getHeight()
{
return 442;
}
}
20 changes: 20 additions & 0 deletions tests/PinterestTest.php
@@ -0,0 +1,20 @@
<?php

namespace Embed\Tests;

class PinterestTest extends AbstractTestCase
{
public function testOne()
{
$this->assertEmbed(
'https://www.pinterest.com/pin/106890191127977979/',
[
'title' => 'Icons',
'width' => 236,
'height' => 442,
'code' => '<a data-pin-do="embedPin" data-pin-lang="es" href="https://www.pinterest.com/pin/106890191127977979/"></a><script async defer src="//assets.pinterest.com/js/pinit.js"></script>',
'providerName' => 'Pinterest',
]
);
}
}

0 comments on commit b211d2d

Please sign in to comment.