Decryptor::decrypt()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 15
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 9
nc 1
nop 2
1
<?php
2
3
namespace Codecraft63\CertsignLogin;
4
5
class Decryptor
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