Source for file Primitive.php

Documentation is available at Primitive.php

  1. <?php
  2. /**
  3. * FIT Fixture: PrimitiveFixture
  4. *
  5. * $Id$
  6. *
  7. * @author Luis A. Floreani <luis.floreani@gmail.com>
  8. * @author gERD Schaufelberger <gerd@php-tools.net>
  9. * @package FIT
  10. * @subpackage Fixture
  11. * @license LGPL http://www.gnu.org/copyleft/lesser.html
  12. * @copyright Copyright (c) 2002-2005 Cunningham & Cunningham, Inc.
  13. */
  14.  
  15. /**
  16. * FIT Fixture: ActionFixture
  17. *
  18. * A PrimitiveFixture is primitive in that it relies on fundamentals
  19. * and is free of adornment.
  20. *
  21. * @version 0.1.0
  22. * @package FIT
  23. * @subpackage Fixture
  24. */
  25. class PHPFIT_Fixture_Primitive extends PHPFIT_Fixture {
  26.  
  27. /**
  28. * parse string ans expect a floating point value
  29. *
  30. * @param Parse cell
  31. * @return float
  32. */
  33. private function parseLong( $cell )
  34. {
  35. if( strpos( $cell->text(), '.' ) === false ) {
  36. throw new Exception( 'NumberFormatException: For input string: "' . $cell->text(). '"');
  37. }
  38.  
  39. return (float) $cell->text();
  40. }
  41. /**
  42. * @param Parse cell
  43. * @param string/int value
  44. */
  45. public function check( $cell, $value )
  46. {
  47. if( !is_numeric( $value ) ) {
  48. if( $cell->text() == $value ) {
  49. $this->right( $cell );
  50. return;
  51. }
  52. $this->wrong($cell, $value);
  53. return;
  54. }
  55. // integer values
  56. if( is_int( $value ) ) {
  57. $v = (int) $cell->text();
  58. if( $v == $value ) {
  59. $this->right( $cell );
  60. return;
  61. }
  62. $this->wrong( $cell, $value );
  63. return;
  64. }
  65. // floating point number
  66. $v = $this->parseLong( $cell );
  67. if( $v == $value ) {
  68. $this->right( $cell );
  69. return;
  70. }
  71. $this->wrong($cell, $value);
  72. return;
  73. }
  74. }
  75. ?>

Documentation generated on Sun, 02 Apr 2006 23:20:52 +0000 by phpDocumentor 1.3.0RC5