2
2
3
3
namespace JohnnyHuy \Laravel \Inline \Renderer ;
4
4
5
- use League \CommonMark \HtmlElement ;
6
- use League \CommonMark \Util \Configuration ;
7
- use League \CommonMark \ElementRendererInterface ;
5
+ use ErrorException ;
8
6
use JohnnyHuy \Laravel \Inline \Element \SoundCloud ;
7
+ use League \CommonMark \ElementRendererInterface ;
8
+ use League \CommonMark \HtmlElement ;
9
9
use League \CommonMark \Inline \Element \AbstractInline ;
10
- use League \CommonMark \Util \ConfigurationAwareInterface ;
11
10
use League \CommonMark \Inline \Element \AbstractWebResource ;
12
11
use League \CommonMark \Inline \Renderer \InlineRendererInterface ;
12
+ use League \CommonMark \Util \Configuration ;
13
13
14
14
class SoundCloudRenderer implements InlineRendererInterface
15
15
{
@@ -20,10 +20,10 @@ class SoundCloudRenderer implements InlineRendererInterface
20
20
21
21
/**
22
22
* @param AbstractInline|AbstractWebResource $inline
23
- * @param \League\CommonMark\ ElementRendererInterface $htmlRenderer
23
+ * @param ElementRendererInterface $htmlRenderer
24
24
*
25
- * @return \League\CommonMark\ HtmlElement|string
26
- * @throws \ ErrorException
25
+ * @return HtmlElement|string
26
+ * @throws ErrorException
27
27
*/
28
28
public function render (AbstractInline $ inline , ElementRendererInterface $ htmlRenderer )
29
29
{
@@ -35,16 +35,16 @@ public function render(AbstractInline $inline, ElementRendererInterface $htmlRen
35
35
$ url = "https://soundcloud.com/oembed?&format=json&url= {$ inline ->getUrl ()}&maxheight=166 " ;
36
36
$ soundCloud = $ this ->getContent ($ url );
37
37
38
- //seems that the used soundcloud url is invalid
39
- //or soundcloud is currently not available
40
- if (is_null ( $ soundCloud) ) {
41
- throw new \ ErrorException ('SoundCloud request returned null: ' . $ url );
38
+ // Seems that the used SoundCloud url is invalid
39
+ // or SoundCloud is currently not available
40
+ if ($ soundCloud === null ) {
41
+ throw new ErrorException ('SoundCloud request returned null: ' . $ url );
42
42
}
43
43
44
- //parse the oembed response
44
+ // Parse the embed response
45
45
$ soundCloud = json_decode ($ soundCloud );
46
46
47
- //use the oembed html snippet as response
47
+ // Use the embed html snippet as response
48
48
return $ soundCloud ->html ;
49
49
}
50
50
0 commit comments