TokenBucketData   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 86
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 0
dl 0
loc 86
ccs 0
cts 15
cp 0
rs 10
c 0
b 0
f 0

6 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 6 1
A getCapacity() 0 4 1
A getRate() 0 4 1
A getStorage() 0 4 1
A toJson() 0 4 1
A toArray() 0 4 1
1
<?php
2
3
/**
4
 * This file is part of laravel-quota
5
 *
6
 * (c) David Faith <[email protected]>
7
 *
8
 * Full copyright and license information is available
9
 * in the LICENSE file distributed with this source code.
10
 */
11
12
namespace Projectmentor\Quota\Stubs;
13
14
use Projectmentor\Quota\Contracts\PayloadInterface;
15
16
/**
17
 * This is the TokenBucket data class.
18
 *
19
 * It stubs constructor parameters for:
20
 * bandwithThottle\tokenBucket\TokenBucket
21
 *
22
 * Initial properties for a new TokenBucket instance via
23
 * \Projectmentor\Quota\Factories\FactoryInterface
24
 *
25
 * @author David Faith <[email protected]>
26
 */
27
class TokenBucketData implements PayloadInterface
28
{
29
    /**
30
     * The maximum token capacity
31
     * @var int
32
     */
33
    protected $capacity;
34
35
    /**
36
     * The bucket refresh rate
37
     * @var \bandwithThrottle\tokenBucket\Rate
38
     */
39
    protected $rate;
40
41
    /**
42
     * The storage instance
43
     * @var \bandwidthThrottle\tokenBucket\storage\FileStorage
44
     */
45
    protected $storage;
46
47
    /**
48
     * Initialize $this
49
     * @param int $capacity of the bucket
50
     * @param \bandwithThrottle\tokenBucket\Rate
51
     * @param \bandwidthThrottle\tokenBucket\storage\FileStorage
52
     * @return void
0 ignored issues
show
Comprehensibility Best Practice introduced by
Adding a @return annotation to constructors is generally not recommended as a constructor does not have a meaningful return value.

Adding a @return annotation to a constructor is not recommended, since a constructor does not have a meaningful return value.

Please refer to the PHP core documentation on constructors.

Loading history...
53
     */
54
    public function __construct($capacity, $rate, $storage)
55
    {
56
        $this->capacity = $capacity;
57
        $this->rate = $rate;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 5 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
58
        $this->storage = $storage;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
59
    }
60
61
    /**
62
     * Get the token bucket capacity
63
     * i.e: the maximum number of
64
     * tokens available at any time.
65
     *
66
     * @return int
67
     */
68
    public function getCapacity()
69
    {
70
        return $this->capacity;
71
    }
72
73
    /**
74
     * Get Rate instance
75
     *
76
     * @return \bandwidthThrottle\tokenBucket\Rate
0 ignored issues
show
Documentation introduced by
Should the return type not be \bandwithThrottle\tokenBucket\Rate?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
77
     */
78
    public function getRate()
79
    {
80
        return $this->rate;
81
    }
82
83
    /**
84
     * Get the storage instance.
85
     *
86
     * @return \bandwithThrottle\tokenBucket\storage\FileStorage
0 ignored issues
show
Documentation introduced by
Should the return type not be \bandwidthThrottle\tokenBucket\storage\FileStorage?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
87
     */
88
    public function getStorage()
89
    {
90
        return $this->storage;
91
    }
92
93
    /**
94
     * Implements PayloadInterface
95
     * emit json payload.
96
     * @return string
97
     */
98
    public function toJson()
99
    {
100
        return 'Hi';
101
    }
102
103
    /**
104
     * Implements PayloadInterface
105
     * emit array payload.
106
     * @return string
0 ignored issues
show
Documentation introduced by
Should the return type not be string[]?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
107
     */
108
    public function toArray()
109
    {
110
        return ['Hi'];
111
    }
112
}
0 ignored issues
show
Coding Style introduced by
As per coding style, files should not end with a newline character.

This check marks files that end in a newline character, i.e. an empy line.

Loading history...
113