Open Journal Systems  3.3.0
Constraint/Factory.php
1 <?php
2 /*
3  * citeproc-php
4  *
5  * @link http://github.com/seboettg/citeproc-php for the source repository
6  * @copyright Copyright (c) 2016 Sebastian Böttger.
7  * @license https://opensource.org/licenses/MIT
8  */
9 
11 
13 
21 {
22  const NAMESPACE_CONSTRAINTS = "Seboettg\\CiteProc\\Constraint\\";
23 
31  public static function createConstraint($name, $value, $match)
32  {
33  $className = "";
34  $parts = explode("-", $name);
35  array_walk($parts, function ($part) use (&$className) {
36  $className .= ucfirst($part);
37  });
38  $className = self::NAMESPACE_CONSTRAINTS . $className;
39 
40  if (!class_exists($className)) {
41  throw new ClassNotFoundException($className);
42  }
43  return new $className($value, $match);
44  }
45 }
Seboettg\CiteProc\Constraint\Factory\NAMESPACE_CONSTRAINTS
const NAMESPACE_CONSTRAINTS
Definition: Constraint/Factory.php:22
Seboettg\CiteProc\Constraint\Factory
Definition: Constraint/Factory.php:20
Seboettg\CiteProc\Exception\ClassNotFoundException
Definition: ClassNotFoundException.php:22
Seboettg\CiteProc\Constraint\Factory\createConstraint
static createConstraint($name, $value, $match)
Definition: Constraint/Factory.php:31
Seboettg\CiteProc\Constraint
Definition: AbstractConstraint.php:8
Seboettg\CiteProc\Util\Factory
Definition: Util/Factory.php:21