src/Document.php
public function getAdSections()
    {
        if (!empty($this->vastAdNodeList)) {
            return $this->vastAdNodeList;
        }
            
        foreach ($this->domDocument->documentElement->childNodes as $adDomElement) {
            // get Ad tag
            if (!$adDomElement instanceof \DOMElement) {
                continue;
            }

            if ('ad' !== strtolower($adDomElement->tagName)) {
                continue;
            }

            // get Ad type tag
            foreach ($adDomElement->childNodes as $node) {
                if (!($node instanceof \DOMElement)) {
                    continue;
                }

                $type = $node->tagName;

                // create ad section
                $adTypeClassName = '\\Sokil\\Vast\\Ad\\' . $type;
                if (!class_exists($adTypeClassName)) {
                    throw new \Exception('Ad type ' . $type . ' not supported');
                }

                $this->vastAdNodeList[] = new $adTypeClassName($adDomElement);
            }
        }
        
        return $this->vastAdNodeList;
    }
public function getAdSections()
    {
        if (!empty($this->vastAdNodeList)) {
            return $this->vastAdNodeList;
        }
            
        foreach ($this->domDocument->documentElement->childNodes as $adDomElement) {
            // get Ad tag
            if (!$adDomElement instanceof \DOMElement) {
                continue;
            }

            if ('ad' !== strtolower($adDomElement->tagName)) {
                continue;
            }

            // get Ad type tag
            foreach ($adDomElement->childNodes as $node) {
                if (!($node instanceof \DOMElement)) {
                    continue;
                }

                $type = $node->tagName;

                // create ad section
                $adTypeClassName = '\\Sokil\\Vast\\Ad\\' . $type;
                if (!class_exists($adTypeClassName)) {
                    throw new \Exception('Ad type ' . $type . ' not supported');
                }

                $this->vastAdNodeList[] = new $adTypeClassName($adDomElement);
            }
        }
        
        return $this->vastAdNodeList;
    }
public function getAdSections ( ) { if ( ! empty ( $ this -> vastAdNodeList ) ) { return $ this -> vastAdNodeList ; } foreach ( $ this -> domDocument -> documentElement -> childNodes as $ adDomElement ) { // get Ad tag if ( ! $ adDomElement instanceof \ DOMElement ) { continue ; } if ( 'ad' !== strtolower ( $ adDomElement -> tagName ) ) { continue ; } // get Ad type tag foreach ( $ adDomElement -> childNodes as $ node ) { if ( ! ( $ node instanceof \ DOMElement ) ) { continue ; } $ type = $ node -> tagName ; // create ad section $ adTypeClassName = '\\Sokil\\Vast\\Ad\\' . $ type ; if ( ! class_exists ( $ adTypeClassName ) ) { throw new \ Exception ( 'Ad type ' . $ type . ' not supported' ) ; } $ this -> vastAdNodeList [ ] = new $ adTypeClassName ( $ adDomElement ) ; } } return $ this -> vastAdNodeList ; }
Get document ad sections

@return AbstractAdNode[]

@throws \Exception
Get document ad sections