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

Activity::validatedBy()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
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