2016-07-20 16:45:59 +08:00
|
|
|
<?php
|
2020-12-09 13:16:13 +08:00
|
|
|
|
2016-07-20 16:45:59 +08:00
|
|
|
/**
|
|
|
|
* SCSSPHP
|
|
|
|
*
|
2020-12-09 13:16:13 +08:00
|
|
|
* @copyright 2015-2020 Leaf Corcoran
|
2016-07-20 16:45:59 +08:00
|
|
|
*
|
|
|
|
* @license http://opensource.org/licenses/MIT MIT
|
|
|
|
*
|
2019-06-28 09:42:24 +08:00
|
|
|
* @link http://scssphp.github.io/scssphp
|
2016-07-20 16:45:59 +08:00
|
|
|
*/
|
|
|
|
|
2019-06-28 09:42:24 +08:00
|
|
|
namespace ScssPhp\ScssPhp\Base;
|
2016-07-20 16:45:59 +08:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Range
|
|
|
|
*
|
|
|
|
* @author Anthon Pang <anthon.pang@gmail.com>
|
2021-12-30 12:10:34 +00:00
|
|
|
*
|
|
|
|
* @internal
|
2016-07-20 16:45:59 +08:00
|
|
|
*/
|
|
|
|
class Range
|
|
|
|
{
|
2021-12-30 12:10:34 +00:00
|
|
|
/**
|
|
|
|
* @var float|int
|
|
|
|
*/
|
2016-07-20 16:45:59 +08:00
|
|
|
public $first;
|
2021-12-30 12:10:34 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @var float|int
|
|
|
|
*/
|
2016-07-20 16:45:59 +08:00
|
|
|
public $last;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Initialize range
|
|
|
|
*
|
2021-12-30 12:10:34 +00:00
|
|
|
* @param int|float $first
|
|
|
|
* @param int|float $last
|
2016-07-20 16:45:59 +08:00
|
|
|
*/
|
|
|
|
public function __construct($first, $last)
|
|
|
|
{
|
|
|
|
$this->first = $first;
|
|
|
|
$this->last = $last;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Test for inclusion in range
|
|
|
|
*
|
2021-12-30 12:10:34 +00:00
|
|
|
* @param int|float $value
|
2016-07-20 16:45:59 +08:00
|
|
|
*
|
2021-12-30 12:10:34 +00:00
|
|
|
* @return bool
|
2016-07-20 16:45:59 +08:00
|
|
|
*/
|
|
|
|
public function includes($value)
|
|
|
|
{
|
|
|
|
return $value >= $this->first && $value <= $this->last;
|
|
|
|
}
|
|
|
|
}
|