AbstractParam::getConstraints()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 9

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 5
cts 5
cp 1
rs 9.9666
c 0
b 0
f 0
cc 2
nc 2
nop 0
crap 2
1
<?php
2
3
/*
4
 * This file is part of the FOSRestBundle package.
5
 *
6
 * (c) FriendsOfSymfony <http://friendsofsymfony.github.com/>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace FOS\RestBundle\Controller\Annotations;
13
14
use Symfony\Component\Validator\Constraints;
15
16
/**
17
 * {@inheritdoc}
18
 *
19
 * @author Jordi Boggiano <[email protected]>
20
 * @author Boris Guéry <[email protected]>
21
 * @author Ener-Getick <[email protected]>
22
 */
23
abstract class AbstractParam implements ParamInterface
24
{
25
    /** @var string */
26
    public $name;
27
28
    /** @var string */
29
    public $key;
30
31
    /** @var mixed */
32
    public $default;
33
34
    /** @var string */
35
    public $description;
36
37
    /** @var bool */
38
    public $strict = false;
39
40
    /** @var bool */
41
    public $nullable = false;
42
43
    /** @var array */
44
    public $incompatibles = array();
45
46
    /** {@inheritdoc} */
47 27
    public function getName()
48
    {
49 27
        return $this->name;
50
    }
51
52
    /** {@inheritdoc} */
53 30
    public function getDefault()
54
    {
55 30
        return $this->default;
56
    }
57
58
    /** {@inheritdoc} */
59 1
    public function getDescription()
60
    {
61 1
        return $this->description;
62
    }
63
64
    /** {@inheritdoc} */
65 21
    public function getIncompatibilities()
66
    {
67 21
        return $this->incompatibles;
68
    }
69
70
    /** {@inheritdoc} */
71 40
    public function getConstraints()
72
    {
73 40
        $constraints = array();
74 40
        if (!$this->nullable) {
75 31
            $constraints[] = new Constraints\NotNull();
76
        }
77
78 40
        return $constraints;
79
    }
80
81
    /** {@inheritdoc} */
82 29
    public function isStrict()
83
    {
84 29
        return $this->strict;
85
    }
86
87
    /**
88
     * @return string
89
     */
90 29
    protected function getKey()
91
    {
92 29
        return $this->key ?: $this->name;
93
    }
94
}
95