Completed
Push — 2.x ( 335a70...1e4aa5 )
by Sullivan
7s
created

Isbn::getIsoCodesClass()   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 SLLH\IsoCodesValidator\Constraints;
4
5
use SLLH\IsoCodesValidator\AbstractConstraint;
6
use Symfony\Component\Validator\Exception\ConstraintDefinitionException;
7
8
/**
9
 * @Annotation
10
 * @Target({"PROPERTY", "METHOD", "ANNOTATION"})
11
 *
12
 * @author Sullivan Senechal <[email protected]>
13
 */
14
final class Isbn extends AbstractConstraint
15
{
16
    public $message = 'This value is not a valid ISBN.';
17
    public $type = null;
18
19
    /**
20
     * {@inheritdoc}
21
     */
22
    public function __construct($options = null)
23
    {
24
        parent::__construct($options);
25
26
        if ($this->type !== null && !in_array($this->type, [10, 13])) {
27
            throw new ConstraintDefinitionException('The option "type" must be 10 or 13');
28
        }
29
    }
30
31
    /**
32
     * {@inheritdoc}
33
     */
34
    public function getDefaultOption()
35
    {
36
        return 'type';
37
    }
38
39
    /**
40
     * {@inheritdoc}
41
     */
42
    public function getIsoCodesVersion()
43
    {
44
        return '1.2.0';
45
    }
46
47
    /**
48
     * {@inheritdoc}
49
     */
50
    public function getIsoCodesClass()
51
    {
52
        return \IsoCodes\Isbn::class;
53
    }
54
}
55