Completed
Pull Request — master (#33)
by Michael
01:34
created

Openssl::decrypt()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 1
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Dcrypt;
6
7
use Exception;
8
9
class Openssl
10
{
11
    private $cipher, $algo, $key;
12
13
    /**
14
     * Openssl constructor.
15
     *
16
     * @param string $cipher
17
     * @param string $algo
18
     * @param string $key
19
     */
20 1
    public function __construct(string $cipher, string $algo, string $key)
0 ignored issues
show
Unused Code introduced by
The parameter $cipher is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $algo is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
Unused Code introduced by
The parameter $key is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
21
    {
22 1
        [$this->cipher, $this->algo, $this->key] = func_get_args();
23 1
    }
24
25
    /**
26
     * @param string $data
27
     * @return string
28
     * @throws Exception
29
     */
30 1
    public function decrypt(string $data): string
31
    {
32 1
        return OpensslStatic::decrypt($data, $this->key, $this->cipher, $this->algo);
33
    }
34
35
    /**
36
     * @param string $data
37
     * @return string
38
     * @throws Exception
39
     */
40 1
    public function encrypt(string $data): string
41
    {
42 1
        return OpensslStatic::encrypt($data, $this->key, $this->cipher, $this->algo);
43
    }
44
}
45