AbstractParam   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 72
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
wmc 9
lcom 2
cbo 1
dl 0
loc 72
ccs 17
cts 17
cp 1
rs 10
c 0
b 0
f 0

7 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 4 1
A getDefault() 0 4 1
A getDescription() 0 4 1
A getIncompatibilities() 0 4 1
A getConstraints() 0 9 2
A isStrict() 0 4 1
A getKey() 0 4 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