Completed
Pull Request — master (#41)
by Sullivan
02:41
created

Activity   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 2
c 2
b 0
f 0
lcom 0
cbo 2
dl 0
loc 34
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 20 1
A validatedBy() 0 4 1
1
<?php
2
3
namespace Nexy\PayboxDirect\Constraints;
4
5
use Symfony\Component\Validator\Constraints\Choice;
6
use Symfony\Component\Validator\Constraints\ChoiceValidator;
7
8
/**
9
 * @Annotation
10
 * @Target({"PROPERTY", "METHOD", "ANNOTATION"})
11
 *
12
 * @author Sullivan Senechal <[email protected]>
13
 */
14
final class Activity extends Choice
15
{
16
    /**
17
     * {@inheritdoc}
18
     */
19
    public function __construct($options)
20
    {
21
        parent::__construct($options);
22
23
        $this->choices = \Nexy\PayboxDirect\Enum\Activity::getConstants();
24
25
        // Option to choose to show constant or options
26
        $this->message = 'The value you selected is not a valid '
27
            .\Nexy\PayboxDirect\Enum\Activity::class
28
            .' enum value. Valid constants are: '
29
            .implode(', ', \Nexy\PayboxDirect\Enum\Activity::getKeys())
30
            .'.'
31
        ;
32
        $this->multipleMessage = 'One or more of the given '
33
            .\Nexy\PayboxDirect\Enum\Activity::class
34
            .' enum values is invalid. Valid constants are: '
35
            .implode(', ', \Nexy\PayboxDirect\Enum\Activity::getKeys())
36
            .'.'
37
        ;
38
    }
39
40
    /**
41
     * {@inheritdoc}
42
     */
43
    public function validatedBy()
44
    {
45
        return ChoiceValidator::class;
46
    }
47
}
48