private function getVideos(): array {
        $videos = [];

        $topNode = $this->article()->getTopNode();

        if ($topNode instanceof Element && $topNode->parent() instanceof Element) {
            $nodes = $topNode->parent()->find('embed, object, iframe, video');

            foreach ($nodes as $node) {
                if ($node->hasAttribute('src')) {
                    $src = $node->attr('src');
                } else {
                    $src = $node->attr('data');
                }

                $match = array_reduce(self::$VIDEO_PROVIDERS, function($match, $domain) use ($src) {
                    $srcHost = (string)parse_url($src, PHP_URL_HOST);
                    $srcScheme = (string)parse_url($src, PHP_URL_SCHEME);

                    return $match || preg_match('@' . $domain . '$@i', $srcHost) && in_array($srcScheme, ['http', 'https']);
                });

                if (!$match) {
                    $srcPath = parse_url(strtolower($src), PHP_URL_PATH);
                    $srcExtension = pathinfo((string)$srcPath, PATHINFO_EXTENSION);

                    $match = in_array($srcExtension, self::$VIDEO_EXTENSIONS);
                }

                if ($match) {
                    $videos[] = $src;
                }
            }
        }

        return $videos;
    }
private function getVideos(): array {
        $videos = [];

        $topNode = $this->article()->getTopNode();

        if ($topNode instanceof Element && $topNode->parent() instanceof Element) {
            $nodes = $topNode->parent()->find('embed, object, iframe, video');

            foreach ($nodes as $node) {
                if ($node->hasAttribute('src')) {
                    $src = $node->attr('src');
                } else {
                    $src = $node->attr('data');
                }

                $match = array_reduce(self::$VIDEO_PROVIDERS, function($match, $domain) use ($src) {
                    $srcHost = (string)parse_url($src, PHP_URL_HOST);
                    $srcScheme = (string)parse_url($src, PHP_URL_SCHEME);

                    return $match || preg_match('@' . $domain . '$@i', $srcHost) && in_array($srcScheme, ['http', 'https']);
                });

                if (!$match) {
                    $srcPath = parse_url(strtolower($src), PHP_URL_PATH);
                    $srcExtension = pathinfo((string)$srcPath, PATHINFO_EXTENSION);

                    $match = in_array($srcExtension, self::$VIDEO_EXTENSIONS);
                }

                if ($match) {
                    $videos[] = $src;
                }
            }
        }

        return $videos;
    }
private function getVideos ( ) : array { $ videos = [ ] ; $ topNode = $ this -> article ( ) -> getTopNode ( ) ; if ( $ topNode instanceof Element && $ topNode -> parent ( ) instanceof Element ) { $ nodes = $ topNode -> parent ( ) -> find ( 'embed, object, iframe, video' ) ; foreach ( $ nodes as $ node ) { if ( $ node -> hasAttribute ( 'src' ) ) { $ src = $ node -> attr ( 'src' ) ; } else { $ src = $ node -> attr ( 'data' ) ; } $ match = array_reduce ( self :: $ VIDEO_PROVIDERS , function ( $ match , $ domain ) use ( $ src ) { $ srcHost = ( string ) parse_url ( $ src , PHP_URL_HOST ) ; $ srcScheme = ( string ) parse_url ( $ src , PHP_URL_SCHEME ) ; return $ match || preg_match ( '@' . $ domain . '$@i' , $ srcHost ) && in_array ( $ srcScheme , [ 'http' , 'https' ] ) ; } ) ; if ( ! $ match ) { $ srcPath = parse_url ( strtolower ( $ src ) , PHP_URL_PATH ) ; $ srcExtension = pathinfo ( ( string ) $ srcPath , PATHINFO_EXTENSION ) ; $ match = in_array ( $ srcExtension , self :: $ VIDEO_EXTENSIONS ) ; } if ( $ match ) { $ videos [ ] = $ src ; } } } return $ videos ; }
Pulls out videos we like

@return string[]
Pulls out videos we like