Completed
Pull Request — master (#33)
by Michael
01:16
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;
12
    private $algo;
13
    private $key;
14
15
    /**
16
     * Openssl constructor.
17
     *
18
     * @param string $cipher
19
     * @param string $algo
20
     * @param string $key
21
     */
22 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...
23
    {
24 1
        [$this->cipher, $this->algo, $this->key] = func_get_args();
25 1
    }
26
27
    /**
28
     * @param string $data
29
     *
30
     * @throws Exception
31
     *
32
     * @return string
33
     */
34 1
    public function decrypt(string $data): string
35
    {
36 1
        return OpensslStatic::decrypt($data, $this->key, $this->cipher, $this->algo);
37
    }
38
39
    /**
40
     * @param string $data
41
     *
42
     * @throws Exception
43
     *
44
     * @return string
45
     */
46 1
    public function encrypt(string $data): string
47
    {
48 1
        return OpensslStatic::encrypt($data, $this->key, $this->cipher, $this->algo);
49
    }
50
}
51