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

EmailConstraintBuilder   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 0%

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A supportsConstraint() 0 4 1
A buildConstraint() 0 5 1
1
<?php
2
/**
3
 * EmailConstraintBuilder class file
4
 */
5
6
namespace Graviton\SchemaBundle\Constraint\Builder;
7
8
use Graviton\RestBundle\Model\DocumentModel;
9
use Graviton\SchemaBundle\Document\Schema;
10
11
/**
12
 * @author   List of contributors <https://github.com/libgraviton/graviton/graphs/contributors>
13
 * @license  http://opensource.org/licenses/gpl-license.php GNU Public License
14
 * @link     http://swisscom.ch
15
 */
16
class EmailConstraintBuilder implements ConstraintBuilderInterface
17
{
18
    /**
19
     * if this builder supports a given constraint
20
     *
21
     * @param string $type    Field type
22
     * @param array  $options Options
23
     *
24
     * @return bool
25
     */
26
    public function supportsConstraint($type, array $options = [])
27
    {
28
        return ($type === 'Email');
29
    }
30
31
    /**
32
     * Adds constraints to the property
33
     *
34
     * @param string        $fieldName field name
35
     * @param Schema        $property  property
36
     * @param DocumentModel $model     parent model
37
     * @param array         $options   the constraint options
38
     *
39
     * @return Schema the modified property
40
     */
41
    public function buildConstraint($fieldName, Schema $property, DocumentModel $model, array $options)
42
    {
43
        $property->setFormat('email');
44
        return $property;
45
    }
46
}
47