Passed
Pull Request — master (#18)
by Indra
12:21 queued 05:07
created

ApiRateLimit::__construct()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 11
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 3

Importance

Changes 0
Metric Value
eloc 7
c 0
b 0
f 0
dl 0
loc 11
ccs 7
cts 7
cp 1
rs 10
cc 3
nc 3
nop 3
crap 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