Passed
Push — master ( 661b73...ccb1dd )
by Sebastian
08:54 queued 05:17
created

Factory   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 10
dl 0
loc 24
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A createConstraint() 0 13 2
1
<?php
2
/*
1 ignored issue
show
Coding Style introduced by
You must use "/**" style comments for a file comment
Loading history...
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
10
namespace Seboettg\CiteProc\Constraint;
11
use Seboettg\CiteProc\Exception\ClassNotFoundException;
12
13
14
/**
15
 * Class Factory
16
 * @package Seboettg\CiteProc\Constraint
1 ignored issue
show
Coding Style introduced by
There must be exactly one blank line before the tags in a doc comment
Loading history...
17
 *
18
 * @author Sebastian Böttger <[email protected]>
19
 */
3 ignored issues
show
Coding Style introduced by
Missing @category tag in class comment
Loading history...
Coding Style introduced by
Missing @license tag in class comment
Loading history...
Coding Style introduced by
Missing @link tag in class comment
Loading history...
20
class Factory extends \Seboettg\CiteProc\Util\Factory
21
{
22
23
    const NAMESPACE_CONSTRAINTS = "Seboettg\\CiteProc\\Constraint\\";
24
25
    /**
1 ignored issue
show
Coding Style introduced by
Missing short description in doc comment
Loading history...
26
     * @param string $name
2 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
27
     * @param string $value
2 ignored issues
show
Coding Style introduced by
Missing parameter comment
Loading history...
Coding Style introduced by
Tag value for @param tag indented incorrectly; expected 2 spaces but found 1
Loading history...
28
     * @return mixed
1 ignored issue
show
Coding Style introduced by
Tag @return cannot be grouped with parameter tags in a doc comment
Loading history...
29
     * @throws ClassNotFoundException
1 ignored issue
show
Coding Style introduced by
Tag @throws cannot be grouped with parameter tags in a doc comment
Loading history...
30
     */
31 40
    public static function createConstraint($name, $value)
32
    {
33 40
        $className = "";
34 40
        $parts = explode("-", $name);
35 40
        array_walk($parts, function($part) use (&$className) {
0 ignored issues
show
Coding Style introduced by
The opening parenthesis of a multi-line function call should be the last content on the line.
Loading history...
Coding Style introduced by
Expected 1 space after FUNCTION keyword; 0 found
Loading history...
36 40
            $className .= ucfirst($part);
37 40
        });
0 ignored issues
show
Coding Style introduced by
For multi-line function calls, the closing parenthesis should be on a new line.

If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line:

someFunctionCall(
    $firstArgument,
    $secondArgument,
    $thirdArgument
); // Closing parenthesis on a new line.
Loading history...
38
        $className = self::NAMESPACE_CONSTRAINTS . $className;
39
40
        if (!class_exists($className)) {
41
            throw new ClassNotFoundException($className);
42
        }
43
        return new $className($value);
44
    }
45
}