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

ShipmentValidator   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 0%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 1
c 1
b 0
f 0
lcom 0
cbo 5
dl 0
loc 30
ccs 0
cts 27
cp 0
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
B loadValidatorMetadata() 0 27 1
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
}