Range.php 780 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. /**
  3. * SCSSPHP
  4. *
  5. * @copyright 2015 Leaf Corcoran
  6. *
  7. * @license http://opensource.org/licenses/MIT MIT
  8. *
  9. * @link http://leafo.github.io/scssphp
  10. */
  11. namespace Leafo\ScssPhp\Base;
  12. /**
  13. * Range
  14. *
  15. * @author Anthon Pang <anthon.pang@gmail.com>
  16. */
  17. class Range
  18. {
  19. public $first;
  20. public $last;
  21. /**
  22. * Initialize range
  23. *
  24. * @param integer|float $first
  25. * @param integer|float $last
  26. */
  27. public function __construct($first, $last)
  28. {
  29. $this->first = $first;
  30. $this->last = $last;
  31. }
  32. /**
  33. * Test for inclusion in range
  34. *
  35. * @param integer|float $value
  36. *
  37. * @return boolean
  38. */
  39. public function includes($value)
  40. {
  41. return $value >= $this->first && $value <= $this->last;
  42. }
  43. }