Completed
Push — master ( 527d7b...b463b0 )
by Giancarlos
07:13
created

NoteValidator::loadValidatorMetadata()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 64
Code Lines 48

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 63
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 64
ccs 63
cts 63
cp 1
rs 9.3956
c 0
b 0
f 0
cc 1
eloc 48
nc 1
nop 1
crap 1

How to fix   Long Method   

Long Method

Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.

For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.

Commonly applied refactorings include:

1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: Giansalex
5
 * Date: 18/07/2017
6
 * Time: 22:27
7
 */
8
9
namespace Greenter\Xml\Validator;
10
11
use Symfony\Component\Validator\Mapping\ClassMetadata;
12
use Symfony\Component\Validator\Constraints as Assert;
13
14
/**
15
 * Trait NoteValidator
16
 * @package Greenter\Xml\Validator
17
 */
18
trait NoteValidator
19
{
20 6
    public static function loadValidatorMetadata(ClassMetadata $metadata)
21
    {
22 6
        $metadata->addPropertyConstraints('tipoDoc', [
23 6
            new Assert\NotBlank(),
24 6
            new Assert\Length([
25 6
                'min' => 2,
26 6
                'max' => 2,
27 6
            ]),
28 6
        ]);
29 6
        $metadata->addPropertyConstraints('serie', [
30 6
            new Assert\NotBlank(),
31 6
            new Assert\Length([ 'max' => 4]),
32 6
        ]);
33 6
        $metadata->addPropertyConstraints('correlativo', [
34 6
            new Assert\NotBlank(),
35 6
            new Assert\Length(['max' => 8]),
36 6
        ]);
37 6
        $metadata->addPropertyConstraint('fechaEmision', new Assert\Date());
38 6
        $metadata->addPropertyConstraints('tipoDocUsuario', [
39 6
            new Assert\NotBlank(),
40 6
            new Assert\Length(['max' => 1]),
41 6
        ]);
42 6
        $metadata->addPropertyConstraints('numDocUsuario', [
43 6
            new Assert\NotBlank(),
44 6
            new Assert\Length(['max' => 15]),
45 6
        ]);
46 6
        $metadata->addPropertyConstraints('rznSocialUsuario', [
47 6
            new Assert\NotBlank(),
48 6
            new Assert\Length(['max' => 100]),
49 6
        ]);
50 6
        $metadata->addPropertyConstraints('tipoMoneda', [
51 6
            new Assert\NotBlank(),
52 6
            new Assert\Length(['max' => 3]),
53 6
        ]);
54 6
        $metadata->addPropertyConstraint('mtoOperGravadas', new Assert\NotBlank());
55 6
        $metadata->addPropertyConstraint('mtoOperInafectas', new Assert\NotBlank());
56 6
        $metadata->addPropertyConstraint('mtoOperExoneradas', new Assert\NotBlank());
57 6
        $metadata->addPropertyConstraint('mtoImpVenta', new Assert\NotBlank());
58 6
        $metadata->addPropertyConstraint('details', new Assert\Valid());
59 6
        $metadata->addPropertyConstraint('legends', new Assert\Valid());
60 6
        $metadata->addPropertyConstraint('relDocs', new Assert\Valid());
61 6
        $metadata->addPropertyConstraints('codMotivo', [
62 6
            new Assert\NotBlank(),
63 6
            new Assert\Length([
64 6
                'min' => 2,
65 6
                'max' => 2,
66 6
            ]),
67 6
        ]);
68 6
        $metadata->addPropertyConstraints('desMotivo', [
69 6
            new Assert\NotBlank(),
70 6
            new Assert\Length([ 'max' => 250]),
71 6
        ]);
72 6
        $metadata->addPropertyConstraints('tipDocAfectado', [
73 6
            new Assert\NotBlank(),
74 6
            new Assert\Length([
75 6
                'min' => 2,
76 6
                'max' => 2,
77 6
            ]),
78 6
        ]);
79 6
        $metadata->addPropertyConstraints('numDocfectado', [
80 6
            new Assert\NotBlank(),
81 6
            new Assert\Length([ 'max' => 13]),
82 6
        ]);
83
    }
84
}