Code Duplication    Length = 62-63 lines in 2 locations

core/services/commands/attendee/CreateAttendeeCommand.php 1 location

@@ 24-86 (lines=63) @@
21
 * @author        Brent Christensen
22
 * @since         $VID:$
23
 */
24
class CreateAttendeeCommand extends Command implements CommandRequiresCapCheckInterface
25
{
26
27
    /**
28
     * array of details where keys are names of EEM_Attendee model fields
29
     *
30
     * @var array $attendee_details
31
     */
32
    protected $attendee_details;
33
34
    /**
35
     * an existing registration to associate this attendee with
36
     *
37
     * @var EE_Registration $registration
38
     */
39
    protected $registration;
40
41
42
43
    /**
44
     * CreateAttendeeCommand constructor.
45
     *
46
     * @param array            $attendee_details
47
     * @param EE_Registration $registration
48
     */
49
    public function __construct(array $attendee_details, EE_Registration $registration)
50
    {
51
        $this->attendee_details = $attendee_details;
52
        $this->registration = $registration;
53
    }
54
55
56
57
    /**
58
     * @return array
59
     */
60
    public function attendeeDetails()
61
    {
62
        return $this->attendee_details;
63
    }
64
65
66
67
    /**
68
     * @return EE_Registration
69
     */
70
    public function registration()
71
    {
72
        return $this->registration;
73
    }
74
75
76
77
    /**
78
     * @return CapCheckInterface
79
     * @throws InvalidDataTypeException
80
     */
81
    public function getCapCheck()
82
    {
83
        // need cap for non-AJAX admin requests
84
        if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
85
            return new CapCheck('ee_edit_contacts', 'create_new_contact');
86
        }
87
        return new PublicCapabilities('', 'create_new_contact');
88
    }
89

core/services/commands/transaction/CreateTransactionCommand.php 1 location

@@ 24-85 (lines=62) @@
21
 * @author        Brent Christensen
22
 * @since         $VID:$
23
 */
24
class CreateTransactionCommand extends Command implements CommandRequiresCapCheckInterface
25
{
26
27
    /**
28
     * @var EE_Checkout $checkout
29
     */
30
    protected $checkout;
31
32
    /**
33
     * @var array $transaction_details
34
     */
35
    protected $transaction_details;
36
37
38
39
    /**
40
     * CreateTransactionCommand constructor.
41
     *
42
     * @param EE_Checkout $checkout
43
     * @param array       $transaction_details
44
     */
45
    public function __construct(EE_Checkout $checkout = null, array $transaction_details = array())
46
    {
47
        $this->checkout = $checkout;
48
        $this->transaction_details = $transaction_details;
49
    }
50
51
52
53
    /**
54
     * @return CapCheckInterface
55
     * @throws InvalidDataTypeException
56
     */
57
    public function getCapCheck()
58
    {
59
        // need cap for non-AJAX admin requests
60
        if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
61
            // there's no specific caps for editing/creating transactions,
62
            // so that's why we are using ee_edit_registrations
63
            return new CapCheck('ee_edit_registrations', 'create_new_transaction');
64
        }
65
        return new PublicCapabilities('', 'create_new_transaction');
66
    }
67
68
69
70
    /**
71
     * @return EE_Checkout
72
     */
73
    public function checkout()
74
    {
75
        return $this->checkout;
76
    }
77
78
79
80
    /**
81
     * @return array
82
     */
83
    public function transactionDetails()
84
    {
85
        return $this->transaction_details;
86
    }
87
88