depage-xmldb v2.3.1
XML documents in a relational database
Loading...
Searching...
No Matches
IdentifierChecker.php
Go to the documentation of this file.
1<?php
2
12
13namespace Depage\XmlDb\Helpers;
14
15use Depage\XmlDb\Exceptions\XmlDbException;
16
21trait IdentifierChecker
22{
28 protected function checkIdentifier(string $name, string $kind = 'column'): string
29 {
30 if (!preg_match('/^[A-Za-z_][A-Za-z0-9_]*$/', $name)) {
31 throw new XmlDbException("Can not use \"$name\" as a $kind name.");
32 }
33
34 return $name;
35 }
36}
37
38/* vim:set ft=php sw=4 sts=4 fdm=marker et : */