Source for file Summary.php

Documentation is available at Summary.php

  1. <?php
  2.  
  3. # Copyright (c) 2002-2005 Cunningham & Cunningham, Inc.
  4. # Released under the terms of the GNU General Public License version 2 or later.
  5. #
  6. # PHP5 translation by Luis A. Floreani <luis.floreani@gmail.com>
  7.  
  8. /**
  9. * load class Fixture
  10. */
  11. include_once dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'Fixture.php';
  12.  
  13. /**
  14. * load class Parse
  15. */
  16. include_once dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'Parse.php';
  17.  
  18. class Summary extends Fixture {
  19. public static $countKey = "counts";
  20.  
  21. public function doTable($table) {
  22. $this->summary[Summary::$countKey] = $this->counts;
  23. ksort($this->summary);
  24. $table->parts->more = $this->rows(array_keys($this->summary));
  25. }
  26. /**
  27. * @param array keys
  28. * @return Parse
  29. */
  30. protected function rows($keys) {
  31. if (count($keys) > 0) {
  32. $key = $keys[0];
  33. $obj = $this->summary[$key];
  34. if (is_string($obj))
  35. $str = $obj;
  36. else
  37. $str = $obj->toString();
  38.  
  39. $td1 = $this->td($str, null);
  40. $td2 = $this->td($key, $td1);
  41. $result = $this->tr($td2, $this->rows(array_splice($keys, 1)));
  42. if ($key == self::$countKey) {
  43. $this->mark($result);
  44. }
  45. return $result;
  46. } else {
  47. return null;
  48. }
  49. }
  50.  
  51. /**
  52. * @param Parse parts
  53. * @param Parse more
  54. * @return Parse
  55. */
  56. protected function tr($parts, $more) {
  57. return new Parse("tr", null, $parts, $more, true);
  58. }
  59. /**
  60. * @param string body
  61. * @param Parse more
  62. * @return Parse
  63. */
  64. protected function td($body, $more) {
  65. return new Parse("td", $this->infoS($body), null, $more, true);
  66. }
  67. /**
  68. * @param Parse row
  69. */
  70. protected function mark($row) {
  71. $official = $this->counts;
  72. $this->counts = new Counts();
  73. $cell = $row->parts->more;
  74. if (($official->wrong + $official->exceptions) > 0) {
  75. $this->wrong($cell);
  76. } else {
  77. $this->right($cell);
  78. }
  79. $this->counts = $official;
  80. }
  81. }
  82.  
  83. ?>

Documentation generated on Sun, 02 Apr 2006 16:01:06 +0200 by phpDocumentor 1.3.0RC5