WebDriverDimension.php 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. // Copyright 2004-present Facebook. All Rights Reserved.
  3. //
  4. // Licensed under the Apache License, Version 2.0 (the "License");
  5. // you may not use this file except in compliance with the License.
  6. // You may obtain a copy of the License at
  7. //
  8. // http://www.apache.org/licenses/LICENSE-2.0
  9. //
  10. // Unless required by applicable law or agreed to in writing, software
  11. // distributed under the License is distributed on an "AS IS" BASIS,
  12. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. // See the License for the specific language governing permissions and
  14. // limitations under the License.
  15. namespace Facebook\WebDriver;
  16. /**
  17. * Represent a dimension.
  18. */
  19. class WebDriverDimension
  20. {
  21. /**
  22. * @var int
  23. */
  24. private $height;
  25. /**
  26. * @var int
  27. */
  28. private $width;
  29. /**
  30. * @param int $width
  31. * @param int $height
  32. */
  33. public function __construct($width, $height)
  34. {
  35. $this->width = $width;
  36. $this->height = $height;
  37. }
  38. /**
  39. * Get the height.
  40. *
  41. * @return int The height.
  42. */
  43. public function getHeight()
  44. {
  45. return $this->height;
  46. }
  47. /**
  48. * Get the width.
  49. *
  50. * @return int The width.
  51. */
  52. public function getWidth()
  53. {
  54. return $this->width;
  55. }
  56. /**
  57. * Check whether the given dimension is the same as the instance.
  58. *
  59. * @param WebDriverDimension $dimension The dimension to be compared with.
  60. * @return bool Whether the height and the width are the same as the instance.
  61. */
  62. public function equals(WebDriverDimension $dimension)
  63. {
  64. return $this->height === $dimension->getHeight() && $this->width === $dimension->getWidth();
  65. }
  66. }