ApiRateLimit   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 3
eloc 12
c 1
b 0
f 0
dl 0
loc 33
ccs 8
cts 8
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 11 3
1
<?php
2
3
/*
4
 * This file is part of the ApiRateLimitBundle
5
 *
6
 * (c) Indra Gunawan <[email protected]>
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 Indragunawan\ApiRateLimitBundle\Annotation;
13
14
/**
15
 * @Annotation
16
 * @Target({"CLASS"})
17
 *
18
 * @author Indra Gunawan <[email protected]>
19
 */
20
#[\Attribute(\Attribute::TARGET_CLASS)]
21
final class ApiRateLimit
22
{
23 9
    public function __construct($enabled = true, array $throttle = [], array $methods = [])
24
    {
25 9
        if (\is_array($enabled)) {
26
            // supports doctrine annotations
27 8
            foreach ($enabled as $key => $value) {
28 8
                $this->$key = $value;
29
            }
30
        } else {
31 1
            $this->enabled = $enabled;
32 1
            $this->throttle = $throttle;
33 1
            $this->methods = $methods;
34
        }
35 9
    }
36
37
    /**
38
     * @var bool
39
     */
40
    public $enabled = true;
41
42
    /**
43
     * @var array
44
     */
45
    public $throttle = [];
46
47
    /**
48
     * @var array
49
     *
50
     * @example ["GET", "POST"]
51
     */
52
    public $methods = [];
53
}
54