public function collect(\SimpleXMLElement $xml, $rootDir)
    {
        $root = rtrim($rootDir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;

        if ($this->jsonFile === null) {
            $this->jsonFile = new JsonFile();
        }

        // overwrite if run_at has already been set
        $runAt = $this->collectRunAt($xml);
        $this->jsonFile->setRunAt($runAt);

        $xpaths = [
            '/coverage/project/file',
            '/coverage/project/package/file',
        ];

        foreach ($xpaths as $xpath) {
            foreach ($xml->xpath($xpath) as $file) {
                $srcFile = $this->collectFileCoverage($file, $root);

                if ($srcFile !== null) {
                    $this->jsonFile->addSourceFile($srcFile);
                }
            }
        }

        return $this->jsonFile;
    }
public function collect(\SimpleXMLElement $xml, $rootDir)
    {
        $root = rtrim($rootDir, DIRECTORY_SEPARATOR) . DIRECTORY_SEPARATOR;

        if ($this->jsonFile === null) {
            $this->jsonFile = new JsonFile();
        }

        // overwrite if run_at has already been set
        $runAt = $this->collectRunAt($xml);
        $this->jsonFile->setRunAt($runAt);

        $xpaths = [
            '/coverage/project/file',
            '/coverage/project/package/file',
        ];

        foreach ($xpaths as $xpath) {
            foreach ($xml->xpath($xpath) as $file) {
                $srcFile = $this->collectFileCoverage($file, $root);

                if ($srcFile !== null) {
                    $this->jsonFile->addSourceFile($srcFile);
                }
            }
        }

        return $this->jsonFile;
    }
public function collect ( \ SimpleXMLElement $ xml , $ rootDir ) { $ root = rtrim ( $ rootDir , DIRECTORY_SEPARATOR ) . DIRECTORY_SEPARATOR ; if ( $ this -> jsonFile === null ) { $ this -> jsonFile = new JsonFile ( ) ; } // overwrite if run_at has already been set $ runAt = $ this -> collectRunAt ( $ xml ) ; $ this -> jsonFile -> setRunAt ( $ runAt ) ; $ xpaths = [ '/coverage/project/file' , '/coverage/project/package/file' , ] ; foreach ( $ xpaths as $ xpath ) { foreach ( $ xml -> xpath ( $ xpath ) as $ file ) { $ srcFile = $ this -> collectFileCoverage ( $ file , $ root ) ; if ( $ srcFile !== null ) { $ this -> jsonFile -> addSourceFile ( $ srcFile ) ; } } } return $ this -> jsonFile ; }
Collect coverage from XML object.

@param \SimpleXMLElement $xml     clover XML object
@param string            $rootDir path to repository root directory

@return \PhpCoveralls\Bundle\CoverallsBundle\Entity\JsonFile
Collect coverage from XML object .