OctetSequenceJWKSpecification   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 38
Duplicated Lines 36.84 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 3
dl 14
loc 38
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 14 14 2
A getSharedSecret() 0 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 namespace jwk\impl;
2
/**
3
 * Copyright 2015 OpenStack Foundation
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 * http://www.apache.org/licenses/LICENSE-2.0
8
 * Unless required by applicable law or agreed to in writing, software
9
 * distributed under the License is distributed on an "AS IS" BASIS,
10
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11
 * See the License for the specific language governing permissions and
12
 * limitations under the License.
13
 **/
14
use jwa\JSONWebSignatureAndEncryptionAlgorithms;
15
use jwk\exceptions\InvalidJWKAlgorithm;
16
use jwk\JSONWebKeyPublicKeyUseValues;
17
use jwk\OctetSequenceKeysParameters;
18
/**
19
 * Class OctetSequenceJWKSpecification
20
 * @package jwk\impl
21
 */
22
final class OctetSequenceJWKSpecification extends JWKSpecification
23
{
24
25
    const GenerateSecret = '';
26
    /**
27
     * @var string
28
     */
29
    private $shared_secret;
30
31
    /**
32
     * @param string $shared_secret
33
     * @param string $alg
34
     * @param string $use
35
     * @throws InvalidJWKAlgorithm
36
     */
37 View Code Duplication
    public function __construct
0 ignored issues
show
Duplication introduced by
This method 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...
38
    (
39
        $shared_secret = self::GenerateSecret,
40
        $alg = JSONWebSignatureAndEncryptionAlgorithms::HS256,
41
        $use = JSONWebKeyPublicKeyUseValues::Signature
42
    )
43
    {
44
        if(!in_array($alg, OctetSequenceKeysParameters::$valid_algorithms_values))
45
            throw new InvalidJWKAlgorithm(sprintf('alg %s', $alg));
46
47
        parent::__construct($alg, $use);
48
49
        $this->shared_secret = $shared_secret;
50
    }
51
52
    /**
53
     * @return string
54
     */
55
    public function getSharedSecret()
56
    {
57
        return $this->shared_secret;
58
    }
59
}