ILIAS  release_8 Revision v8.24
Alphanumeric.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
5/* Copyright (c) 1998-2019 ILIAS open source, Extended GPL, see docs/LICENSE */
6
11namespace ILIAS\Data;
12
14
16{
20 private $value;
21
26 public function __construct($value)
27 {
28 $matches = null;
29 if (!preg_match('/^[a-zA-Z0-9]+$/', (string) $value, $matches)) {
31 sprintf('The value "%s" is not an alphanumeric value.', $value),
32 'exception_not_alphanumeric',
33 array($value)
34 );
35 }
36
37 $this->value = $value;
38 }
39
43 public function getValue()
44 {
45 return $this->value;
46 }
47
48 public function asString(): string
49 {
50 return (string) $this->value;
51 }
52}