public function convert($data)
    {
        $data = trim($data);

        try {

            // Buffer engine used to convert the html string into DOMElements,
            $engine = new FabricationEngine;
            $engine->run($data);

            // Check if the body is null, so use the head if avaliable.
            if ($engine->getBody()->item(0) == null) {

                $node = $engine->getHead()->item(0)->childNodes->item(0);

                return $this->importNode($node, true);
            }

            if ($engine->getBody()->item(0) !== null) {

                // body first item.
                $node = $engine->getBody()->item(0)->childNodes->item(0);

                return $this->importNode($node, true);
            }

            return false;
        } catch (\Exception $e) {

            return('FabricationEngine :: convert : ' . $e->getMessage());
        }
    }
public function convert($data)
    {
        $data = trim($data);

        try {

            // Buffer engine used to convert the html string into DOMElements,
            $engine = new FabricationEngine;
            $engine->run($data);

            // Check if the body is null, so use the head if avaliable.
            if ($engine->getBody()->item(0) == null) {

                $node = $engine->getHead()->item(0)->childNodes->item(0);

                return $this->importNode($node, true);
            }

            if ($engine->getBody()->item(0) !== null) {

                // body first item.
                $node = $engine->getBody()->item(0)->childNodes->item(0);

                return $this->importNode($node, true);
            }

            return false;
        } catch (\Exception $e) {

            return('FabricationEngine :: convert : ' . $e->getMessage());
        }
    }
public function convert ( $ data ) { $ data = trim ( $ data ) ; try { // Buffer engine used to convert the html string into DOMElements,
 $ engine = new FabricationEngine ; $ engine -> run ( $ data ) ; // Check if the body is null, so use the head if avaliable.
 if ( $ engine -> getBody ( ) -> item ( 0 ) == null ) { $ node = $ engine -> getHead ( ) -> item ( 0 ) -> childNodes -> item ( 0 ) ; return $ this -> importNode ( $ node , true ) ; } if ( $ engine -> getBody ( ) -> item ( 0 ) !== null ) { // body first item.
 $ node = $ engine -> getBody ( ) -> item ( 0 ) -> childNodes -> item ( 0 ) ; return $ this -> importNode ( $ node , true ) ; } return false ; } catch ( \ Exception $ e ) { return ( 'FabricationEngine :: convert : ' . $ e -> getMessage ( ) ) ; } }
Helper to allow the import of a html string into the current engine,
without causing DOM hierarchy errors.

This method generate's a temporary engine DOM structure from the data
Will return the body first child, if null the head first child.
Then the engine will call importNode using the found node and return the
DOM structure.

@param string $data

@return mixed
Helper to allow the import of a html string into the current engine without causing DOM hierarchy errors .