ILIAS  release_7 Revision v7.30-3-g800a261c036
Alphanumeric.php
Go to the documentation of this file.
1<?php
2declare(strict_types=1);
3
4/* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
5
10namespace ILIAS\Data;
11
13
15{
19 private $value;
20
25 public function __construct($value)
26 {
27 $matches = null;
28 if (!preg_match('/^[a-zA-Z0-9]+$/', (string) $value, $matches)) {
30 sprintf('The value "%s" is not an alphanumeric value.', $value),
31 'exception_not_alphanumeric',
32 array($value)
33 );
34 }
35
36 $this->value = $value;
37 }
38
42 public function getValue()
43 {
44 return $this->value;
45 }
46
50 public function asString() : string
51 {
52 return (string) $this->value;
53 }
54}
An exception for terminatinating execution or to throw for unit testing.