Completed
Push — master ( 6ba45c...e1d569 )
by Giancarlos
04:03
created

DespatchValidator::loadValidatorMetadata()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 32
Code Lines 24

Duplication

Lines 32
Ratio 100 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 32
loc 32
ccs 0
cts 32
cp 0
rs 8.8571
cc 1
eloc 24
nc 1
nop 1
crap 2
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: Administrador
5
 * Date: 08/08/2017
6
 * Time: 10:18 AM
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 DespatchValidator
16
 * @package Greenter\Xml\Validator
17
 */
18 View Code Duplication
trait DespatchValidator
0 ignored issues
show
Duplication introduced by
This class 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...
19
{
20
    public static function loadValidatorMetadata(ClassMetadata $metadata)
21
    {
22
        $metadata->addPropertyConstraints('tipoDoc', [
23
            new Assert\NotBlank(),
24
            new Assert\Length(['max' => 2]),
25
        ]);
26
        $metadata->addPropertyConstraints('serie', [
27
            new Assert\NotBlank(),
28
            new Assert\Length(['max' => 4]),
29
        ]);
30
        $metadata->addPropertyConstraints('correlativo', [
31
            new Assert\NotBlank(),
32
            new Assert\Length(['max' => 8]),
33
        ]);
34
        $metadata->addPropertyConstraint('observacion', new Assert\Length(['max' => 250]));
35
        $metadata->addPropertyConstraint('fechaEmision', new Assert\Date());
36
        $metadata->addPropertyConstraints('destinatario', [
37
            new Assert\NotBlank(),
38
            new Assert\Valid(),
39
        ]);
40
        $metadata->addPropertyConstraint('tercero', new Assert\Valid());
41
        $metadata->addPropertyConstraints('envio', [
42
            new Assert\NotBlank(),
43
            new Assert\Valid(),
44
        ]);
45
        $metadata->addPropertyConstraint('docBaja', new Assert\Valid());
46
        $metadata->addPropertyConstraint('relDocs', new Assert\Valid());
47
        $metadata->addPropertyConstraints('details', [
48
            new Assert\NotBlank(),
49
            new Assert\Valid(),
50
        ]);
51
    }
52
}