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