Numbers::isInRange()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 1
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 1
nc 2
nop 3
dl 0
loc 2
ccs 1
cts 1
cp 1
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
4
namespace Nexendrie\Utils;
5
6
/**
7
 * Numbers
8
 *
9
 * @author Jakub Konečný
10
 */
11 1
final class Numbers {
12
  use \Nette\StaticClass;
13
  
14
  /**
15
   * Ensure that a number is within boundaries
16
   */
17
  public static function range(int $number, int $min, int $max): int {
18 1
    return min(max($number, $min), $max);
19
  }
20
  
21
  /**
22
   * Check whether a number is within boundaries
23
   */
24
  public static function isInRange(int $number, int $min, int $max): bool {
25 1
    return ($number >= $min && $number <= $max);
26
  }
27
}
28
?>