PluginProbe
MaxButtons – Create buttons / 7.13.2
MaxButtons – Create buttons v7.13.2
6.23 6.24 6.25 6.26 6.26.1 6.27 6.28 6.3 6.4 6.5 6.6 6.7 6.8 6.9 7.0 7.1 7.1.1 7.1.2 7.1.3 7.10 7.11 7.13 7.13.1 7.13.2 7.13.3 All 100 releases
maxbuttons / assets / libraries / scssphp / src / Util.php

Util.php in MaxButtons – Create buttons 7.13.2, at assets/libraries/scssphp/src/Util.php

71 lines 1.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * SCSSPHP
4 *
5 * @copyright 2012-2018 Leaf Corcoran
6 *
7 * @license http://opensource.org/licenses/MIT MIT
8 *
9 * @link http://leafo.github.io/scssphp
10 */
11
12 namespace Leafo\ScssPhp;
13
14 use Leafo\ScssPhp\Base\Range;
15 use Leafo\ScssPhp\Exception\RangeException;
16
17 /**
18 * Utilty functions
19 *
20 * @author Anthon Pang <anthon.pang@gmail.com>
21 */
22 class Util
23 {
24 /**
25 * Asserts that `value` falls within `range` (inclusive), leaving
26 * room for slight floating-point errors.
27 *
28 * @param string $name The name of the value. Used in the error message.
29 * @param \Leafo\ScssPhp\Base\Range $range Range of values.
30 * @param array $value The value to check.
31 * @param string $unit The unit of the value. Used in error reporting.
32 *
33 * @return mixed `value` adjusted to fall within range, if it was outside by a floating-point margin.
34 *
35 * @throws \Leafo\ScssPhp\Exception\RangeException
36 */
37 public static function checkRange($name, Range $range, $value, $unit = '')
38 {
39 $val = $value[1];
40 $grace = new Range(-0.00001, 0.00001);
41
42 if ($range->includes($val)) {
43 return $val;
44 }
45
46 if ($grace->includes($val - $range->first)) {
47 return $range->first;
48 }
49
50 if ($grace->includes($val - $range->last)) {
51 return $range->last;
52 }
53
54 throw new RangeException("$name {$val} must be between {$range->first} and {$range->last}$unit");
55 }
56
57 /**
58 * Encode URI component
59 *
60 * @param string $string
61 *
62 * @return string
63 */
64 public static function encodeURIComponent($string)
65 {
66 $revert = array('%21' => '!', '%2A' => '*', '%27' => "'", '%28' => '(', '%29' => ')');
67
68 return strtr(rawurlencode($string), $revert);
69 }
70 }
71