|
Moodle
2.2.1
http://www.collinsharper.com
|
00001 <?php 00002 /* 00003 * $Id: CoverageXmlParser.php,v 1.2 2010/12/14 17:36:00 moodlerobot Exp $ 00004 * 00005 * Copyright(c) 2004-2006, SpikeSource Inc. All Rights Reserved. 00006 * Licensed under the Open Software License version 2.1 00007 * (See http://www.spikesource.com/license.html) 00008 */ 00009 ?> 00010 <?php 00011 00012 require_once dirname(__FILE__) . "/BasicXmlParser.php"; 00013 00031 class CoverageXmlParser extends BasicXmlParser { 00032 /*{{{ Members */ 00033 00034 protected $_data = array(); 00035 protected $_lastFilePath; 00036 00037 /*}}}*/ 00038 /*{{{ public function startHandler() */ 00039 00040 public function startHandler($xp, $name, $attrs) { 00041 switch($name) { 00042 case "FILE": 00043 $fileAttributes = $this->handleAttrTag($name, $attrs); 00044 $this->_lastFilePath = $fileAttributes["PATH"]; 00045 if(!isset($this->_data[$this->_lastFilePath])) { 00046 $this->_data[$this->_lastFilePath] = array(); 00047 } 00048 break; 00049 00050 case "LINE": 00051 $lineAttributes = $this->handleAttrTag($name, $attrs); 00052 $lineNumber = (int)$lineAttributes["LINE-NUMBER"]; 00053 if(!isset($this->_data[$this->_lastFilePath][$lineNumber])) { 00054 $this->_data[$this->_lastFilePath][$lineNumber] = (int)$lineAttributes["FREQUENCY"]; 00055 } 00056 else { 00057 $this->_data[$this->_lastFilePath][$lineNumber] += (int)$lineAttributes["FREQUENCY"]; 00058 } 00059 break; 00060 } 00061 } 00062 00063 /*}}}*/ 00064 /*{{{ public function getCoverageData() */ 00065 00086 public function getCoverageData() { 00087 return $this->_data; 00088 } 00089 00090 /*}}}*/ 00091 } 00092 ?>