/** * Dumps to source code * * @return string The sourcecode */ public function dump() { $methods = $this->specification->getMethods(); $result = '<?php /* * This file is part of PHP Selenium Library. * (c) Alexandre Salomé <*****@*****.**> * * For the full copyright and license information, please view the LICENSE * file that was distributed with this source code. */ namespace Selenium; /** * Browser class containing all methods of Selenium Server, with documentation. * * This class was generated, do not modify it. * * @author Alexandre Salomé <*****@*****.**> */ class GeneratedBrowser extends BaseBrowser { '; foreach ($methods as $method) { $result .= $this->dumpMethod($method) . "\n\n"; } $result .= "}\n"; return $result; }
/** * Loads the specification from a XML file * * @param string $file Path to the file to load */ public function load($file) { if (!file_exists($file)) { throw new \RuntimeException(sprintf('The file "%s" does not exists', $file)); } $content = file_get_contents($file); // HACK: DOMNode seems to bug when a node is named "param" $content = str_replace('<param', '<parameter', $content); $content = str_replace('</param', '</parameter', $content); $crawler = new Crawler(); $crawler->addContent($content, 'xml'); foreach ($crawler->filterXPath('//function') as $node) { $method = $this->getMethod($node); $this->specification->addMethod($method); } }