Completed
Branch FET-9795-new-interfaces (ea072c)
by
unknown
118:13 queued 96:20
created

RegCode   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 52
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 52
rs 10
wmc 2
lcom 0
cbo 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 21 1
A __toString() 0 3 1
1
<?php
2
namespace EventEspresso\core\domain\entities;
3
4
if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
5
	exit( 'No direct script access allowed' );
6
}
7
8
9
10
/**
11
 * Class RegCode
12
 * generates a REG_code
13
 *
14
 * @package       Event Espresso
15
 * @author        Brent Christensen
16
 * @since         4.9.1
17
 */
18
class RegCode {
19
20
21
	/*
22
	 * @var string $reg_code
23
	 */
24
	private $reg_code;
25
26
27
28
	/**
29
	 * RegCode constructor.
30
	 *
31
	 * @param RegUrlLink $reg_url_link
32
	 * @param \EE_Transaction $transaction
33
	 * @param \EE_Ticket $ticket
34
	 */
35
	public function __construct(
36
		RegUrlLink $reg_url_link,
37
		\EE_Transaction $transaction,
38
		\EE_Ticket $ticket
39
	) {
40
		// figure out where to start parsing the reg code
41
		$chars = strpos( $reg_url_link, '-' ) + 5;
42
		// TXN_ID + TKT_ID + first 3 and last 3 chars of reg_url_link
43
		$this->reg_code = array(
0 ignored issues
show
Documentation Bug introduced by
It seems like array($transaction->ID()...g_url_link, 0, $chars)) of type array<integer,?,{"0":"?"..."string","2":"string"}> is incompatible with the declared type string of property $reg_code.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
44
			$transaction->ID(),
45
			$ticket->ID(),
46
			substr( $reg_url_link, 0, $chars )
47
		);
48
		// now put it all together
49
		$this->reg_code = apply_filters(
50
			'FHEE__Create__regCode__new_reg_code',
51
			implode( '-', $this->reg_code ),
52
			$transaction,
53
			$ticket
54
		);
55
	}
56
57
58
59
	/**
60
	 * Return the object as a string
61
	 *
62
	 * @return string
63
	 */
64
	public function __toString() {
65
		return $this->reg_code;
66
	}
67
68
69
}
70
// End of file RegCode.php
71
// Location: /RegCode.php