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