Completed
Push — master ( 93ef1f...d80a95 )
by Christophe
13:13
created

AbstractParam::resolve()   C

Complexity

Conditions 8
Paths 4

Size

Total Lines 46
Code Lines 26

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 27
CRAP Score 8

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 46
ccs 27
cts 27
cp 1
rs 5.5556
cc 8
eloc 26
nc 4
nop 1
crap 8
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
    /** @var string */
28
    public $key;
29
    /** @var mixed */
30
    public $default;
31
    /** @var string */
32
    public $description;
33
    /** @var bool */
34
    public $strict = false;
35
    /** @var bool */
36
    public $nullable = false;
37
    /** @var array */
38
    public $incompatibles = array();
39
40
    /** {@inheritdoc} */
41
    public function getName()
42
    {
43
        return $this->name;
44
    }
45 7
46
    /** {@inheritdoc} */
47 7
    public function getDefault()
48
    {
49
        return $this->default;
50
    }
51 6
52
    /** {@inheritdoc} */
53 6
    public function getDescription()
54
    {
55
        return $this->description;
56
    }
57 1
58
    /** {@inheritdoc} */
59 1
    public function getIncompatibilities()
60
    {
61
        return $this->incompatibles;
62
    }
63 4
64
    /** {@inheritdoc} */
65 4
    public function getConstraints()
66
    {
67
        $constraints = array();
68
        if (!$this->nullable) {
69 12
            $constraints[] = new Constraints\NotNull();
70
        }
71 12
72 12
        return $constraints;
73 11
    }
74 11
75
    /** {@inheritdoc} */
76 12
    public function isStrict()
77
    {
78
        return $this->strict;
79
    }
80 1
81
    /**
82 1
     * @return string
83
     */
84
    protected function getKey()
85
    {
86
        return $this->key ?: $this->name;
87
    }
88
}
89