Signer   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
wmc 4
eloc 9
c 2
b 0
f 0
dl 0
loc 41
rs 10

4 Methods

Rating   Name   Duplication   Size   Complexity  
A sign() 0 5 1
A policy() 0 3 1
A perform() 0 4 1
A __construct() 0 4 1
1
<?php
2
declare(strict_types=1);
3
4
/**
5
 * Signature Provider Class
6
 * @category    Ticaje
7
 * @author      Max Demian <[email protected]>
8
 */
9
10
namespace Ticaje\AeSdk\Infrastructure\Provider\Signature;
11
12
use Ticaje\AeSdk\Infrastructure\Interfaces\Provider\Signature\SignatureInterface;
13
use Ticaje\AeSdk\Infrastructure\Interfaces\Provider\Request\RequestDtoInterface as DtoInterface;
14
use Ticaje\AeSdk\Infrastructure\Interfaces\Provider\Signature\SignerInterface;
15
16
/**
17
 * Class Signer
18
 * @package Ticaje\AeSdk\Infrastructure\Provider\Signature
19
 */
20
class Signer implements SignerInterface
21
{
22
    private $algorithmer;
23
24
    public function __construct(
25
        SignatureInterface $algorithmer
26
    ) {
27
        $this->algorithmer = $algorithmer;
28
    }
29
30
    /**
31
     * @inheritDoc
32
     */
33
    public function sign(string $toSign, DtoInterface $dto): string
34
    {
35
        $secret = $dto->getAppSecret();
0 ignored issues
show
Bug introduced by
The method getAppSecret() does not exist on Ticaje\AeSdk\Infrastruct...est\RequestDtoInterface. Since it exists in all sub-types, consider adding an abstract or default implementation to Ticaje\AeSdk\Infrastruct...est\RequestDtoInterface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

35
        /** @scrutinizer ignore-call */ 
36
        $secret = $dto->getAppSecret();
Loading history...
36
        $result = strtoupper($this->algorithmer->sign($this->perform($toSign, $secret)));
0 ignored issues
show
Bug introduced by
The method sign() does not exist on Ticaje\AeSdk\Infrastruct...ture\SignatureInterface. Since it exists in all sub-types, consider adding an abstract or default implementation to Ticaje\AeSdk\Infrastruct...ture\SignatureInterface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

36
        $result = strtoupper($this->algorithmer->/** @scrutinizer ignore-call */ sign($this->perform($toSign, $secret)));
Loading history...
37
        return $result;
38
    }
39
40
    /**
41
     * @param string $sorted
42
     * @param string $secret
43
     * @return string
44
     * This method accomplishes business policy
45
     */
46
    private function perform(string $sorted, string $secret)
47
    {
48
        $data = $this->policy($secret, $sorted);
49
        return $data;
50
    }
51
52
    /**
53
     * @param $secret
54
     * @param $data
55
     * @return string
56
     * This is the business policy being met
57
     */
58
    private function policy($secret, $data)
59
    {
60
        return $secret . $data . $secret;
61
    }
62
}
63