JweEncryptionCollection   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 51
Duplicated Lines 100 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
dl 51
loc 51
c 0
b 0
f 0
wmc 5
lcom 1
cbo 1
rs 10

5 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 4 4 1
A add() 6 6 1
A get() 4 4 1
A has() 4 4 1
A all() 4 4 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
3
/*
4
 * This file is part of the tmilos/jose-jwt package.
5
 *
6
 * (c) Milos Tomic <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
namespace Tmilos\JoseJwt\Jwe;
13
14
use Tmilos\JoseJwt\Util\ParameterBag;
15
16 View Code Duplication
class JweEncryptionCollection
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
17
{
18
    /** @var ParameterBag */
19
    private $bag;
20
21
    public function __construct()
22
    {
23
        $this->bag = new ParameterBag();
24
    }
25
26
    /**
27
     * @param string        $id
28
     * @param JweEncryption $algorithm
29
     *
30
     * @return JweEncryptionCollection
31
     */
32
    public function add($id, JweEncryption $algorithm)
33
    {
34
        $this->bag->set($id, $algorithm);
35
36
        return $this;
37
    }
38
39
    /**
40
     * @param string $id
41
     *
42
     * @return JweEncryption
43
     */
44
    public function get($id)
45
    {
46
        return $this->bag->get($id, null);
47
    }
48
49
    /**
50
     * @param string $id
51
     *
52
     * @return bool
53
     */
54
    public function has($id)
55
    {
56
        return $this->bag->has($id);
57
    }
58
59
    /**
60
     * @return JweEncryption[] id => JweEncryption
61
     */
62
    public function all()
63
    {
64
        return $this->bag->all();
65
    }
66
}
67