Signature   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 9
dl 0
loc 34
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A sign() 0 7 1
1
<?php
2
namespace PomeloPHP\Crypt;
3
4
use PomeloPHP\Model\Transaction;
5
6
class Signature
7
{
8
    /**
9
     * @var Transaction
10
     */
11
    private $transaction;
12
13
14
    /**
15
     * @var string
16
     */
17
    private $apiKey;
18
19
    /**
20
     * Signature constructor.
21
     * @param Transaction $transaction
22
     * @param string $apiKey
23
     */
24
    public function __construct(Transaction $transaction, $apiKey)
25
    {
26
        $this->transaction = $transaction;
27
        $this->apiKey = $apiKey;
28
    }
29
30
    /**
31
     * @return string
32
     */
33
    public function sign()
34
    {
35
        $str = 'amount='.$this->transaction->getAmount().
36
            '&currency='.$this->transaction->getCurrency().
37
            '&apiKey='.$this->apiKey;
38
39
        return sha1($str);
40
    }
41
}
42