File tree Expand file tree Collapse file tree 4 files changed +99
-0
lines changed Expand file tree Collapse file tree 4 files changed +99
-0
lines changed Original file line number Diff line number Diff line change 1+ <?php
2+ /**
3+ * Adapter to get the embed code from line.do
4+ */
5+ namespace Embed \Adapters ;
6+
7+ use Embed \Viewers ;
8+ use Embed \Request ;
9+
10+ class Line extends Webpage implements AdapterInterface
11+ {
12+ /**
13+ * {@inheritDoc}
14+ */
15+ public static function check (Request $ request )
16+ {
17+ return $ request ->match (array (
18+ 'https://line.do/* ' ,
19+ ));
20+ }
21+
22+ /**
23+ * {@inheritDoc}
24+ */
25+ public function getCode ()
26+ {
27+ $ url = clone $ this ->request ->url ;
28+
29+ $ url ->setDirectory (0 , 'embed ' );
30+ $ url ->setDirectory (2 , 'vertical ' );
31+
32+ return Viewers::iframe ($ url ->getUrl (), $ this ->width , $ this ->height );
33+ }
34+
35+ /**
36+ * {@inheritDoc}
37+ */
38+ public function getWidth ()
39+ {
40+ return 640 ;
41+ }
42+
43+ /**
44+ * {@inheritDoc}
45+ */
46+ public function getHeight ()
47+ {
48+ return 640 ;
49+ }
50+ }
Original file line number Diff line number Diff line change @@ -147,6 +147,28 @@ public function getDomain($first_level = false)
147147 }
148148 }
149149
150+ /**
151+ * Edit a specific directory in the path of the url
152+ *
153+ * @param int $key The position of the subdirectory (0 based index)
154+ * @param string $value The new value
155+ */
156+ public function setDirectory ($ key , $ value )
157+ {
158+ if ($ key > count ($ this ->info ['path ' ])) {
159+ $ this ->info ['path ' ][] = $ this ->info ['file ' ];
160+ $ this ->info ['file ' ] = $ value ;
161+ return ;
162+ }
163+
164+ if ($ key === count ($ this ->info ['path ' ])) {
165+ $ this ->info ['file ' ] = $ value ;
166+ return ;
167+ }
168+
169+ $ this ->info ['path ' ][$ key ] = $ value ;
170+ }
171+
150172 /**
151173 * Return a specific directory in the path of the url
152174 *
Original file line number Diff line number Diff line change 1+ <?php
2+ include_once dirname (__DIR__ ).'/src/autoloader.php ' ;
3+
4+ class SoundcloudTest extends PHPUnit_Framework_TestCase
5+ {
6+ public function testOne ()
7+ {
8+ $ info = Embed \Embed::create ('https://line.do/embed/8oq/vertical ' );
9+
10+ $ this ->assertEquals ($ info ->title , 'PHP Evolution ' );
11+ $ this ->assertEquals ($ info ->type , 'rich ' );
12+ $ this ->assertEquals ($ info ->code , '<iframe src="https://line.do/embed/8oq/vertical" frameborder="0" allowTransparency="true" style="border:none;overflow:hidden;width:640px;height:640px;"></iframe> ' );
13+ $ this ->assertEquals ($ info ->width , 640 );
14+ $ this ->assertEquals ($ info ->height , 640 );
15+ $ this ->assertEquals ($ info ->providerName , 'line ' );
16+ $ this ->assertEquals ($ info ->providerUrl , 'https://line.do ' );
17+ }
18+ }
Original file line number Diff line number Diff line change @@ -26,6 +26,15 @@ public function testDirectory()
2626 $ this ->assertEquals ('second ' , $ url ->getDirectory (1 ));
2727 $ this ->assertEquals ('third ' , $ url ->getDirectory (2 ));
2828 $ this ->assertNull ($ url ->getDirectory (3 ));
29+
30+ $ url ->setDirectory (0 , 'one ' );
31+ $ url ->setDirectory (2 , 'four ' );
32+
33+ $ this ->assertEquals ('one ' , $ url ->getDirectory (0 ));
34+ $ this ->assertEquals ('four ' , $ url ->getDirectory (2 ));
35+ $ this ->assertNull ($ url ->getDirectory (3 ));
36+
37+ $ this ->assertEquals ('http://domain.com/one/second/four ' , $ url ->getUrl ());
2938 }
3039
3140 public function testDomain ()
You can’t perform that action at this time.
0 commit comments