Passed
Push — master ( b8e26c...2f113f )
by Remco
05:42
created

Message   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 36
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A is_valid() 0 4 1
A get_signature() 0 2 1
A set_signature() 0 2 1
1
<?php
2
/**
3
 * Message
4
 *
5
 * @author    Pronamic <[email protected]>
6
 * @copyright 2005-2018 Pronamic
7
 * @license   GPL-3.0-or-later
8
 * @package   Pronamic\WordPress\Pay\Gateways\OmniKassa2
9
 */
10
11
namespace Pronamic\WordPress\Pay\Gateways\OmniKassa2;
12
13
/**
14
 * Message
15
 *
16
 * @author  Remco Tolsma
17
 * @version 2.0.2
18
 * @since   2.0.2
19
 */
20
abstract class Message implements Signable {
21
	/**
22
	 * Signature.
23
	 *
24
	 * @var string
25
	 */
26
	private $signature;
27
28
	/**
29
	 * Get signature.
30
	 *
31
	 * @return string
32
	 */
33
	public function get_signature() {
34
		return $this->signature;
35
	}
36
37
	/**
38
	 * Set signature.
39
	 *
40
	 * @param string $signature Signature.
41
	 */
42
	protected function set_signature( $signature ) {
43
		$this->signature = $signature;
44
	}
45
46
	/**
47
	 * Check if this message is valid.
48
	 *
49
	 * @param string $signing_key Signing key.
50
	 * @return bool True if valid, false otherwise.
51
	 */
52
	public function is_valid( $signing_key ) {
53
		$signature = Security::get_signature( $this, $signing_key );
54
55
		return Security::validate_signature( $signature, $this->get_signature() );
56
	}
57
}
58