Completed
Push — master ( 4ddcf1...b67918 )
by Ramon
11:18
created

Decryptor   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 28
Duplicated Lines 100 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A decrypt() 15 15 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
namespace Codecraft63\CertsignLogin;
4
5 View Code Duplication
class Decryptor
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...
6
{
7
    use Util;
8
9
    /**
10
     * Decrypt text using certsign login private key.
11
     *
12
     * @param string $input
13
     * @param string $key
14
     * @throws \Exception
15
     * @return string
16
     */
17
    public static function decrypt(string $input, string $key): string
18
    {
19
        list($cipher, $iv_size, $key_size) = self::getCipher();
0 ignored issues
show
Unused Code introduced by
The assignment to $key_size is unused. Consider omitting it like so list($first,,$third).

This checks looks for assignemnts to variables using the list(...) function, where not all assigned variables are subsequently used.

Consider the following code example.

<?php

function returnThreeValues() {
    return array('a', 'b', 'c');
}

list($a, $b, $c) = returnThreeValues();

print $a . " - " . $c;

Only the variables $a and $c are used. There was no need to assign $b.

Instead, the list call could have been.

list($a,, $c) = returnThreeValues();
Loading history...
20
        $iv = substr($key, 0, $iv_size);
21
        $key = substr($key, 0, $iv_size);
22
23
        mcrypt_generic_init($cipher, $key, $iv);
24
25
        $data = base64_decode(str_replace("certplus", "\\+", $input));
26
27
        $data = mdecrypt_generic($cipher, $data);
28
        self::finalizeCipher($cipher);
29
30
        return trim($data);
31
    }
32
}
33