Conditions | 3 |
Paths | 3 |
Total Lines | 16 |
Code Lines | 11 |
Lines | 0 |
Ratio | 0 % |
Tests | 10 |
CRAP Score | 3.0067 |
Changes | 1 | ||
Bugs | 0 | Features | 0 |
1 | <?php |
||
33 | 63 | public static function createConstraint(string $name, string $value, string $match): Constraint |
|
34 | { |
||
35 | 63 | $parts = explode("-", $name); |
|
36 | $className = implode("", array_map(function (string $part) { |
||
37 | 63 | return ucfirst($part); //use locale-safe ucfirst function |
|
38 | 63 | }, $parts)); |
|
39 | 63 | $className = self::NAMESPACE_CONSTRAINTS . $className; |
|
40 | |||
41 | 63 | if (!class_exists($className)) { |
|
42 | throw new ClassNotFoundException($className); |
||
43 | } |
||
44 | 63 | $constraint = new $className($value, $match); |
|
45 | 63 | if ($constraint instanceof RenderingObserver) { |
|
46 | 51 | CiteProc::getContext()->addObserver($constraint); |
|
47 | } |
||
48 | 63 | return $constraint; |
|
49 | } |
||
51 |