Source for file ArithmeticColumnFixture.php

Documentation is available at ArithmeticColumnFixture.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. require_once Fixture::INCLUDE_DIR . DIRECTORY_SEPARATOR . 'ColumnFixture.php';
  9.  
  10. class ArithmeticColumnFixture extends ColumnFixture {
  11. public $x = 0;
  12. public $y = 0; // not 0 to avoid that getReturnType (for floating() and divide()) throws an Exception
  13. public function plus() {
  14. return intval($this->x + $this->y);
  15. }
  16.  
  17. public function minus() {
  18. return intval($this->x - $this->y);
  19. }
  20.  
  21. public function times() {
  22. return intval($this->x * $this->y);
  23. }
  24.  
  25. public function divide() {
  26. if ($this->y == 0)
  27. throw new Exception("ArithmeticException: / by zero");
  28. return intval($this->x / $this->y);
  29. }
  30.  
  31. public function floating() {
  32. if ($this->y == 0)
  33. throw new Exception("ArithmeticException: / by zero");
  34. return floatval($this->x / $this->y);
  35. }
  36.  
  37. /*
  38. public ScientificDouble sin () {
  39. return new ScientificDouble(Math.sin(Math.toRadians(x)));
  40. }
  41. */
  42. public $typeDict = array(
  43. "x" => "integer",
  44. "y" => "integer",
  45. "plus" => "integer",
  46. "minus" => "integer",
  47. "times" => "integer",
  48. "divide" => "integer",
  49. "floating" => "double"
  50. );
  51.  
  52.  
  53. }
  54.  
  55. ?>

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