Margin.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <?php
  2. /*
  3. * This file is part of the php-phantomjs.
  4. *
  5. * For the full copyright and license information, please view the LICENSE
  6. * file that was distributed with this source code.
  7. */
  8. namespace JonnyW\PhantomJs\Page;
  9. /**
  10. * PHP PhantomJs.
  11. *
  12. * @author Jon Wenmoth <contact@jonnyw.me>
  13. */
  14. class Margin implements \JsonSerializable
  15. {
  16. /**
  17. * Top.
  18. *
  19. * @var int
  20. */
  21. private $top;
  22. /**
  23. * Left.
  24. *
  25. * @var int
  26. */
  27. private $left;
  28. /**
  29. * Bottom.
  30. *
  31. * @var int
  32. */
  33. private $bottom;
  34. /**
  35. * Right.
  36. *
  37. * @var int
  38. */
  39. private $right;
  40. /**
  41. * Internal constructor.
  42. *
  43. * @param int $top (default: 0)
  44. * @param int $left (default: 0)
  45. * @param int $bottom (default: 0)
  46. * @param int $right (default: 0)
  47. */
  48. public function __construct($top = 0, $left = 0, $bottom = 0, $right = 0)
  49. {
  50. $this->top = (int) $top;
  51. $this->left = (int) $left;
  52. $this->bottom = (int) $bottom;
  53. $this->right = (int) $right;
  54. }
  55. /**
  56. * Format data for JSON serialization.
  57. *
  58. * @return array
  59. */
  60. public function jsonSerialize()
  61. {
  62. return array(
  63. 'top' => $this->top,
  64. 'left' => $this->left,
  65. 'bottom' => $this->bottom,
  66. 'right' => $this->right,
  67. );
  68. }
  69. }