@@ -33,20 +33,20 @@ private function detectFromEmbed(): ?EmbedCode
3333
3434 private function detectFromOpenGraph (): ?EmbedCode
3535 {
36- $ document = $ this ->extractor ->getDocument ();
36+ $ metas = $ this ->extractor ->getMetas ();
3737
38- $ url = $ document -> meta ('og:video:secure_url ' , 'og:video:url ' , 'og:video ' );
38+ $ url = $ metas -> url ('og:video:secure_url ' , 'og:video:url ' , 'og:video ' );
3939
4040 if (!$ url ) {
4141 return null ;
4242 }
4343
44- if (!($ path = parse_url ( $ url , PHP_URL_PATH )) || !( $ type = pathinfo ($ path , PATHINFO_EXTENSION ))) {
45- $ type = $ document -> meta ('og:video_type ' );
44+ if (!($ type = pathinfo ($ url -> getPath () , PATHINFO_EXTENSION ))) {
45+ $ type = $ metas -> str ('og:video_type ' );
4646 }
4747
48- $ width = $ document -> meta ('twitter:player:width ' );
49- $ height = $ document -> meta ('twitter:player:height ' );
48+ $ width = $ metas -> int ('twitter:player:width ' );
49+ $ height = $ metas -> int ('twitter:player:height ' );
5050
5151 switch ($ type ) {
5252 case 'swf ' :
@@ -77,25 +77,21 @@ private function detectFromOpenGraph(): ?EmbedCode
7777 ]);
7878 }
7979
80- return new EmbedCode (
81- $ code ,
82- $ width ? (int ) $ width : null ,
83- $ height ? (int ) $ height : null
84- );
80+ return new EmbedCode ($ code , $ width , $ height );
8581 }
8682
8783 private function detectFromTwitter (): ?EmbedCode
8884 {
89- $ document = $ this ->extractor ->getDocument ();
85+ $ metas = $ this ->extractor ->getMetas ();
9086
91- $ url = $ document -> meta ('twitter:player ' );
87+ $ url = $ metas -> url ('twitter:player ' );
9288
9389 if (!$ url ) {
9490 return null ;
9591 }
9692
97- $ width = $ document -> meta ('twitter:player:width ' );
98- $ height = $ document -> meta ('twitter:player:height ' );
93+ $ width = $ metas -> int ('twitter:player:width ' );
94+ $ height = $ metas -> int ('twitter:player:height ' );
9995
10096 $ code = html ('iframe ' , [
10197 'src ' => $ url ,
@@ -105,10 +101,6 @@ private function detectFromTwitter(): ?EmbedCode
105101 'allowTransparency ' => 'true ' ,
106102 ]);
107103
108- return new EmbedCode (
109- $ code ,
110- $ width ? (int ) $ width : null ,
111- $ height ? (int ) $ height : null
112- );
104+ return new EmbedCode ($ code , $ width , $ height );
113105 }
114106}
0 commit comments