Commit f670b474 authored by David Maus's avatar David Maus
Browse files

Factor out subfield code pattern

* src/HAB/Pica/Record/Subfield.php ($validSubfieldCodePattern): New property.
  (isValidSubfieldCode): Factor out subfield code pattern.
parent e7115ab7
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
* *
* @package PicaRecord * @package PicaRecord
* @author David Maus <maus@hab.de> * @author David Maus <maus@hab.de>
* @copyright Copyright (c) 2012, 2013 by Herzog August Bibliothek Wolfenbüttel * @copyright Copyright (c) 2012 - 2016 by Herzog August Bibliothek Wolfenbüttel
* @license http://www.gnu.org/licenses/gpl.html GNU General Public License v3 * @license http://www.gnu.org/licenses/gpl.html GNU General Public License v3
*/ */
...@@ -33,6 +33,12 @@ use InvalidArgumentException; ...@@ -33,6 +33,12 @@ use InvalidArgumentException;
class Subfield class Subfield
{ {
/**
* Regular expression matching a valid subfield code.
*
* @var string
*/
public static $validSubfieldCodePattern = '/^[a-z0-9]$/Di';
/** /**
* Return true if argument is a valid subfield code. * Return true if argument is a valid subfield code.
...@@ -42,7 +48,7 @@ class Subfield ...@@ -42,7 +48,7 @@ class Subfield
*/ */
public static function isValidSubfieldCode ($arg) public static function isValidSubfieldCode ($arg)
{ {
return (bool)preg_match('/^[a-z0-9]$/Di', $arg); return (bool)preg_match(self::$validSubfieldCodePattern, $arg);
} }
/** /**
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment