Completed
Push — master ( bc4a85...ef080e )
by
unknown
02:43
created

RateLimit::setPayload()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 3
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 3
cts 3
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Noxlogic\RateLimitBundle\Annotation;
4
5
use Doctrine\Common\Annotations\Annotation;
6
use Sensio\Bundle\FrameworkExtraBundle\Configuration\ConfigurationAnnotation;
7
8
/**
9
 * @Annotation
10
 * @Target({"METHOD", "CLASS"})
11
 */
12
class RateLimit extends ConfigurationAnnotation
13
{
14
    /**
15
     * @var array HTTP Methods protected by this annotation. Defaults to all method
16
     */
17
    protected $methods = array();
18
19
    /**
20
     * @var int Number of calls per period
21
     */
22
    protected $limit = -1;
23
24
    /**
25
     * @var int Number of seconds of the time period in which the calls can be made
26
     */
27
    protected $period = 3600;
28
29
    /**
30
     * @var mixed Generic payload
31
     */
32
    protected $payload;
33
34
    /**
35
     * Returns the alias name for an annotated configuration.
36
     *
37
     * @return string
38
     */
39 1
    public function getAliasName()
40
    {
41 1
        return "x-rate-limit";
42
    }
43
44
    /**
45
     * Returns whether multiple annotations of this type are allowed
46
     *
47
     * @return Boolean
48
     */
49 1
    public function allowArray()
50
    {
51 1
        return true;
52
    }
53
54
    /**
55
     * @return int
56
     */
57 16
    public function getLimit()
58
    {
59 16
        return $this->limit;
60
    }
61
62
    /**
63
     * @param int $limit
64
     */
65 23
    public function setLimit($limit)
66
    {
67 23
        $this->limit = $limit;
68 23
    }
69
70
    /**
71
     * @return array
72
     */
73 24
    public function getMethods()
74
    {
75 24
        return $this->methods;
76
    }
77
78
    /**
79
     * @param array $methods
80
     */
81 13
    public function setMethods($methods)
82
    {
83 13
        $this->methods = (array) $methods;
84 13
    }
85
86
    /**
87
     * @return int
88
     */
89 16
    public function getPeriod()
90
    {
91 16
        return $this->period;
92
    }
93
94
    /**
95
     * @param int $period
96
     */
97 23
    public function setPeriod($period)
98
    {
99 23
        $this->period = $period;
100 23
    }
101
102
    /**
103
     * @return mixed
104
     */
105 10
    public function getPayload()
106
    {
107 10
        return $this->payload;
108
    }
109
110
    /**
111
     * @param mixed $payload
112
     */
113 2
    public function setPayload($payload)
114
    {
115 2
        $this->payload = $payload;
116 2
    }
117
118
}
119