Signature::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
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