Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9709e2c
commit b211d2d
Showing
2 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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', | ||
] | ||
); | ||
} | ||
} |