ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
PositiveInteger.php
Go to the documentation of this file.
1<?php
2declare(strict_types=1);
3/* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
4
9namespace ILIAS\Data;
10
12
14{
18 private $value;
19
24 public function __construct(int $value)
25 {
26 $matches = null;
27
28 if ($value < 0) {
30 sprintf('The value "%s" is not a positive integer', $value),
31 'exception_not_positive_integer',
32 array($value)
33 );
34 }
35
36 $this->value = $value;
37 }
38
42 public function getValue() : int
43 {
44 return (int) $this->value;
45 }
46}
An exception for terminatinating execution or to throw for unit testing.