forked from ILIAS-eLearning/ILIAS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPositiveInteger.php
46 lines (38 loc) · 896 Bytes
/
PositiveInteger.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
declare(strict_types=1);
/* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
/**
* @author Niels Theen <[email protected]>
*/
namespace ILIAS\Data;
use ILIAS\Refinery\ConstraintViolationException;
class PositiveInteger
{
/**
* @var int
*/
private $value;
/**
* @param int $value
* @throws ConstraintViolationException
*/
public function __construct(int $value)
{
$matches = null;
if ($value < 0) {
throw new ConstraintViolationException(
sprintf('The value "%s" is not a positive integer', $value),
'exception_not_positive_integer',
array($value)
);
}
$this->value = $value;
}
/**
* @return int
*/
public function getValue() : int
{
return (int) $this->value;
}
}