Skip to content

Commit 10c96b2

Browse files
committed
Added ideone.com support #156
1 parent 2266eaf commit 10c96b2

File tree

2 files changed

+53
-0
lines changed

2 files changed

+53
-0
lines changed

src/Adapters/Ideone.php

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
<?php
2+
3+
namespace Embed\Adapters;
4+
5+
use Embed\Request;
6+
use Embed\Utils;
7+
8+
/**
9+
* Adapter to generate embed code from ideone.com.
10+
*/
11+
class Ideone extends Webpage implements AdapterInterface
12+
{
13+
/**
14+
* {@inheritdoc}
15+
*/
16+
public static function check(Request $request)
17+
{
18+
return $request->isValid() && $request->match([
19+
'https?://ideone.com/*',
20+
]);
21+
}
22+
23+
/**
24+
* {@inheritdoc}
25+
*/
26+
public function getCode()
27+
{
28+
$this->width = null;
29+
$this->height = null;
30+
31+
$path = '/e.js'.$this->request->getPath();
32+
33+
return Utils::script($this->request->createUrl($path)->getUrl());
34+
}
35+
}

tests/IdeoneTest.php

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
class IdeoneTest extends TestCaseBase
4+
{
5+
public function testOne()
6+
{
7+
$this->assertEmbed(
8+
'http://ideone.com/Whjntg',
9+
[
10+
'title' => 'Ideone.com',
11+
'type' => 'rich',
12+
'providerName' => 'Ideone.com',
13+
'providerUrl' => 'http://ideone.com',
14+
'code' => '<script src="http://ideone.com/e.js/Whjntg"></script>'
15+
]
16+
);
17+
}
18+
}

0 commit comments

Comments
 (0)