Completed
Push — feature/EVO-5751-text-index-mo... ( 0ab3ac...8fecb1 )
by
unknown
62:16 queued 57:01
created

ConstraintNormalizer::normalize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 9

Duplication

Lines 15
Ratio 100 %

Code Coverage

Tests 11
CRAP Score 1

Importance

Changes 1
Bugs 1 Features 0
Metric Value
c 1
b 1
f 0
dl 15
loc 15
rs 9.4285
ccs 11
cts 11
cp 1
cc 1
eloc 9
nc 1
nop 1
crap 1
1
<?php
2
/**
3
 * ConstraintNormalizer class file
4
 */
5
namespace Graviton\GeneratorBundle\Definition\Utils;
6
7
use Graviton\GeneratorBundle\Definition\Schema\Constraint;
8
use Graviton\GeneratorBundle\Definition\Schema\ConstraintOption;
9
10
/**
11
 * Constraint normalizer
12
 *
13
 * @author   List of contributors <https://github.com/libgraviton/graviton/graphs/contributors>
14
 * @license  http://opensource.org/licenses/gpl-license.php GNU Public License
15
 * @link     http://swisscom.ch
16
 */
17
class ConstraintNormalizer
0 ignored issues
show
Coding Style introduced by
ConstraintNormalizer does not seem to conform to the naming convention (Utils?$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
18
{
19
    /**
20
     * Convert constraint to array to selerialile it via json_encode
21
     *
22
     * @param Constraint $constraint Constraint
23
     * @return array
0 ignored issues
show
Documentation introduced by
Consider making the return type a bit more specific; maybe use array<string,string|array>.

This check looks for the generic type array as a return type and suggests a more specific type. This type is inferred from the actual code.

Loading history...
24
     */
25 6 View Code Duplication
    public static function normalize(Constraint $constraint)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
26
    {
27
        return [
28 6
            'name'      => $constraint->getName(),
29 6
            'options'   => array_map(
30 6
                function (ConstraintOption $option) {
31
                    return [
32 6
                        'name'  => $option->getName(),
33 6
                        'value' => $option->getValue(),
34 3
                    ];
35 6
                },
36 6
                $constraint->getOptions()
37 3
            ),
38 3
        ];
39
    }
40
}
41