ILIAS  trunk Revision v12.0_alpha-1540-g00f839d5fa1
Alphanumeric.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
25namespace ILIAS\Data;
26
28
30{
34 private $value;
35
40 public function __construct($value)
41 {
42 $matches = null;
43 if (!preg_match('/^[a-zA-Z0-9]+$/', (string) $value, $matches)) {
45 sprintf('The value "%s" is not an alphanumeric value.', $value),
46 'exception_not_alphanumeric',
47 array($value)
48 );
49 }
50
51 $this->value = $value;
52 }
53
57 public function getValue()
58 {
59 return $this->value;
60 }
61
62 public function asString(): string
63 {
64 return (string) $this->value;
65 }
66}