Point.php 957 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. namespace Intervention\Image;
  3. class Point
  4. {
  5. /**
  6. * X coordinate
  7. *
  8. * @var int
  9. */
  10. public $x;
  11. /**
  12. * Y coordinate
  13. *
  14. * @var int
  15. */
  16. public $y;
  17. /**
  18. * Creates a new instance
  19. *
  20. * @param int $x
  21. * @param int $y
  22. */
  23. public function __construct($x = null, $y = null)
  24. {
  25. $this->x = is_numeric($x) ? intval($x) : 0;
  26. $this->y = is_numeric($y) ? intval($y) : 0;
  27. }
  28. /**
  29. * Sets X coordinate
  30. *
  31. * @param int $x
  32. */
  33. public function setX($x)
  34. {
  35. $this->x = intval($x);
  36. }
  37. /**
  38. * Sets Y coordinate
  39. *
  40. * @param int $y
  41. */
  42. public function setY($y)
  43. {
  44. $this->y = intval($y);
  45. }
  46. /**
  47. * Sets both X and Y coordinate
  48. *
  49. * @param int $x
  50. * @param int $y
  51. */
  52. public function setPosition($x, $y)
  53. {
  54. $this->setX($x);
  55. $this->setY($y);
  56. }
  57. }