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

ShipmentValidator::loadValidatorMetadata()   B

Complexity

Conditions 1
Paths 1

Size

Total Lines 27
Code Lines 21

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 27
ccs 0
cts 27
cp 0
rs 8.8571
cc 1
eloc 21
nc 1
nop 1
crap 2
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: Administrador
5
 * Date: 08/08/2017
6
 * Time: 10:00 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 ShipmentValidator
16
 * @package Greenter\Xml\Validator
17
 */
18
trait ShipmentValidator
19
{
20
    public static function loadValidatorMetadata(ClassMetadata $metadata)
21
    {
22
        $metadata->addPropertyConstraints('codTraslado', [
23
            new Assert\NotBlank(),
24
            new Assert\Length(['min' => 2, 'max' => 2]),
25
        ]);
26
        $metadata->addPropertyConstraint('desTraslado', new Assert\Length(['max' => 100]));
27
        $metadata->addPropertyConstraint('indTransbordo', new Assert\NotBlank());
28
        $metadata->addPropertyConstraint('pesoTotal', new Assert\NotBlank());
29
        $metadata->addPropertyConstraints('undPesoTotal', [
30
            new Assert\NotBlank(),
31
            new Assert\Length(['max' => 4]),
32
        ]);
33
        $metadata->addPropertyConstraints('modTraslado', [
34
            new Assert\NotBlank(),
35
            new Assert\Length(['min' => 2, 'max' => 2]),
36
        ]);
37
        $metadata->addPropertyConstraints('fecTraslado', [
38
            new Assert\NotBlank(),
39
            new Assert\Date()
40
        ]);
41
        $metadata->addPropertyConstraint('numContenedor', new Assert\Length(['max' => 17]));
42
        $metadata->addPropertyConstraint('codPuerto', new Assert\Length(['max' => 3]));
43
        $metadata->addPropertyConstraint('transportista', new Assert\Valid());
44
        $metadata->addPropertyConstraint('llegada', new Assert\Valid());
45
        $metadata->addPropertyConstraint('partida', new Assert\Valid());
46
    }
47
}