Completed
Branch FET/asset-manager (433489)
by
unknown
32:42 queued 18:11
created
services/commands/registration/CopyRegistrationPaymentsCommandHandler.php 2 patches
Indentation   +32 added lines, -32 removed lines patch added patch discarded remove patch
@@ -21,36 +21,36 @@
 block discarded – undo
21 21
 {
22 22
 
23 23
 
24
-    /**
25
-     * @var CopyRegistrationService $copy_registration_service
26
-     */
27
-    private $copy_registration_service;
28
-
29
-
30
-    /**
31
-     * Command constructor
32
-     *
33
-     * @param CopyRegistrationService $copy_registration_service
34
-     */
35
-    public function __construct(CopyRegistrationService $copy_registration_service)
36
-    {
37
-        $this->copy_registration_service = $copy_registration_service;
38
-    }
39
-
40
-
41
-    /**
42
-     * @param \EventEspresso\core\services\commands\CommandInterface $command
43
-     * @return boolean
44
-     */
45
-    public function handle(CommandInterface $command)
46
-    {
47
-        /** @var CopyRegistrationPaymentsCommand $command */
48
-        if (! $command instanceof CopyRegistrationPaymentsCommand) {
49
-            throw new InvalidEntityException(get_class($command), 'CopyRegistrationPaymentsCommand');
50
-        }
51
-        return $this->copy_registration_service->copyPaymentDetails(
52
-            $command->targetRegistration(),
53
-            $command->registrationToCopy()
54
-        );
55
-    }
24
+	/**
25
+	 * @var CopyRegistrationService $copy_registration_service
26
+	 */
27
+	private $copy_registration_service;
28
+
29
+
30
+	/**
31
+	 * Command constructor
32
+	 *
33
+	 * @param CopyRegistrationService $copy_registration_service
34
+	 */
35
+	public function __construct(CopyRegistrationService $copy_registration_service)
36
+	{
37
+		$this->copy_registration_service = $copy_registration_service;
38
+	}
39
+
40
+
41
+	/**
42
+	 * @param \EventEspresso\core\services\commands\CommandInterface $command
43
+	 * @return boolean
44
+	 */
45
+	public function handle(CommandInterface $command)
46
+	{
47
+		/** @var CopyRegistrationPaymentsCommand $command */
48
+		if (! $command instanceof CopyRegistrationPaymentsCommand) {
49
+			throw new InvalidEntityException(get_class($command), 'CopyRegistrationPaymentsCommand');
50
+		}
51
+		return $this->copy_registration_service->copyPaymentDetails(
52
+			$command->targetRegistration(),
53
+			$command->registrationToCopy()
54
+		);
55
+	}
56 56
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -45,7 +45,7 @@
 block discarded – undo
45 45
     public function handle(CommandInterface $command)
46 46
     {
47 47
         /** @var CopyRegistrationPaymentsCommand $command */
48
-        if (! $command instanceof CopyRegistrationPaymentsCommand) {
48
+        if ( ! $command instanceof CopyRegistrationPaymentsCommand) {
49 49
             throw new InvalidEntityException(get_class($command), 'CopyRegistrationPaymentsCommand');
50 50
         }
51 51
         return $this->copy_registration_service->copyPaymentDetails(
Please login to merge, or discard this patch.
core/services/commands/registration/CreateRegistrationCommandHandler.php 2 patches
Indentation   +42 added lines, -42 removed lines patch added patch discarded remove patch
@@ -18,46 +18,46 @@
 block discarded – undo
18 18
 class CreateRegistrationCommandHandler extends CommandHandler
19 19
 {
20 20
 
21
-    /**
22
-     * @var CreateRegistrationService $registration_service
23
-     */
24
-    private $registration_service;
25
-
26
-
27
-    /**
28
-     * Command constructor
29
-     *
30
-     * @param CreateRegistrationService $registration_service
31
-     */
32
-    public function __construct(CreateRegistrationService $registration_service)
33
-    {
34
-        $this->registration_service = $registration_service;
35
-    }
36
-
37
-
38
-    /**
39
-     * @param  CommandInterface $command
40
-     * @return mixed
41
-     * @throws \OutOfRangeException
42
-     * @throws \EventEspresso\core\exceptions\UnexpectedEntityException
43
-     * @throws \EE_Error
44
-     * @throws \EventEspresso\core\exceptions\InvalidEntityException
45
-     */
46
-    public function handle(CommandInterface $command)
47
-    {
48
-        /** @var CreateRegistrationCommand $command */
49
-        if (! $command instanceof CreateRegistrationCommand) {
50
-            throw new InvalidEntityException(get_class($command), 'CreateRegistrationCommand');
51
-        }
52
-        // now create a new registration for the ticket
53
-        return $this->registration_service->create(
54
-            $command->ticket()->get_related_event(),
55
-            $command->transaction(),
56
-            $command->ticket(),
57
-            $command->ticketLineItem(),
58
-            $command->regCount(),
59
-            $command->regGroupSize(),
60
-            $command->regStatus()
61
-        );
62
-    }
21
+	/**
22
+	 * @var CreateRegistrationService $registration_service
23
+	 */
24
+	private $registration_service;
25
+
26
+
27
+	/**
28
+	 * Command constructor
29
+	 *
30
+	 * @param CreateRegistrationService $registration_service
31
+	 */
32
+	public function __construct(CreateRegistrationService $registration_service)
33
+	{
34
+		$this->registration_service = $registration_service;
35
+	}
36
+
37
+
38
+	/**
39
+	 * @param  CommandInterface $command
40
+	 * @return mixed
41
+	 * @throws \OutOfRangeException
42
+	 * @throws \EventEspresso\core\exceptions\UnexpectedEntityException
43
+	 * @throws \EE_Error
44
+	 * @throws \EventEspresso\core\exceptions\InvalidEntityException
45
+	 */
46
+	public function handle(CommandInterface $command)
47
+	{
48
+		/** @var CreateRegistrationCommand $command */
49
+		if (! $command instanceof CreateRegistrationCommand) {
50
+			throw new InvalidEntityException(get_class($command), 'CreateRegistrationCommand');
51
+		}
52
+		// now create a new registration for the ticket
53
+		return $this->registration_service->create(
54
+			$command->ticket()->get_related_event(),
55
+			$command->transaction(),
56
+			$command->ticket(),
57
+			$command->ticketLineItem(),
58
+			$command->regCount(),
59
+			$command->regGroupSize(),
60
+			$command->regStatus()
61
+		);
62
+	}
63 63
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -52,7 +52,7 @@
 block discarded – undo
52 52
     public function handle(CommandInterface $command)
53 53
     {
54 54
         /** @var CreateRegistrationCommand $command */
55
-        if (! $command instanceof CreateRegistrationCommand) {
55
+        if ( ! $command instanceof CreateRegistrationCommand) {
56 56
             throw new InvalidEntityException(get_class($command), 'CreateRegistrationCommand');
57 57
         }
58 58
         // now create a new registration for the ticket
Please login to merge, or discard this patch.
core/services/commands/registration/CreateRegistrationCommand.php 2 patches
Indentation   +147 added lines, -147 removed lines patch added patch discarded remove patch
@@ -24,151 +24,151 @@
 block discarded – undo
24 24
 class CreateRegistrationCommand extends Command implements CommandRequiresCapCheckInterface
25 25
 {
26 26
 
27
-    /**
28
-     * @var EE_Transaction $transaction
29
-     */
30
-    private $transaction;
31
-
32
-    /**
33
-     * @var EE_Ticket $ticket
34
-     */
35
-    private $ticket;
36
-
37
-    /**
38
-     * @var EE_Line_Item $ticket_line_item
39
-     */
40
-    private $ticket_line_item;
41
-
42
-    /**
43
-     * @var int $reg_count
44
-     */
45
-    private $reg_count;
46
-
47
-    /**
48
-     * @var int $reg_group_size
49
-     */
50
-    private $reg_group_size;
51
-
52
-    /**
53
-     * @var string $reg_status
54
-     */
55
-    private $reg_status;
56
-
57
-    /**
58
-     * @var EE_Registration $registration
59
-     */
60
-    protected $registration;
61
-
62
-
63
-    /**
64
-     * CreateRegistrationCommand constructor.
65
-     *
66
-     * @param EE_Transaction $transaction
67
-     * @param EE_Line_Item   $ticket_line_item
68
-     * @param int            $reg_count
69
-     * @param int            $reg_group_size
70
-     * @param string         $reg_status
71
-     * @throws InvalidEntityException
72
-     */
73
-    public function __construct(
74
-        EE_Transaction $transaction,
75
-        EE_Line_Item $ticket_line_item,
76
-        $reg_count = 1,
77
-        $reg_group_size = 0,
78
-        $reg_status = EEM_Registration::status_id_incomplete
79
-    ) {
80
-        // grab the related ticket object for this line_item
81
-        $this->ticket = $ticket_line_item->ticket();
82
-        if (! $this->ticket instanceof EE_Ticket) {
83
-            throw new InvalidEntityException(
84
-                is_object($this->ticket) ? get_class($this->ticket) : gettype($this->ticket),
85
-                'EE_Ticket',
86
-                sprintf(
87
-                    __('Line item %s did not contain a valid ticket', 'event_espresso'),
88
-                    $ticket_line_item->ID()
89
-                )
90
-            );
91
-        }
92
-        $this->transaction = $transaction;
93
-        $this->ticket_line_item = $ticket_line_item;
94
-        $this->reg_count = absint($reg_count);
95
-        $this->reg_group_size = absint($reg_group_size);
96
-        $this->reg_status = $reg_status;
97
-    }
98
-
99
-
100
-    /**
101
-     * @return \EventEspresso\core\domain\services\capabilities\CapCheckInterface
102
-     * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
103
-     */
104
-    public function getCapCheck()
105
-    {
106
-        if (! $this->cap_check instanceof CapCheckInterface) {
107
-            return new CapCheck('ee_edit_registrations', 'create_new_registration');
108
-        }
109
-        return $this->cap_check;
110
-    }
111
-
112
-
113
-    /**
114
-     * @return EE_Transaction
115
-     */
116
-    public function transaction()
117
-    {
118
-        return $this->transaction;
119
-    }
120
-
121
-
122
-    /**
123
-     * @return EE_Ticket
124
-     */
125
-    public function ticket()
126
-    {
127
-        return $this->ticket;
128
-    }
129
-
130
-
131
-    /**
132
-     * @return EE_Line_Item
133
-     */
134
-    public function ticketLineItem()
135
-    {
136
-        return $this->ticket_line_item;
137
-    }
138
-
139
-
140
-    /**
141
-     * @return int
142
-     */
143
-    public function regCount()
144
-    {
145
-        return $this->reg_count;
146
-    }
147
-
148
-
149
-    /**
150
-     * @return int
151
-     */
152
-    public function regGroupSize()
153
-    {
154
-        return $this->reg_group_size;
155
-    }
156
-
157
-
158
-    /**
159
-     * @return string
160
-     */
161
-    public function regStatus()
162
-    {
163
-        return $this->reg_status;
164
-    }
165
-
166
-
167
-    /**
168
-     * @return EE_Registration
169
-     */
170
-    public function registration()
171
-    {
172
-        return $this->registration;
173
-    }
27
+	/**
28
+	 * @var EE_Transaction $transaction
29
+	 */
30
+	private $transaction;
31
+
32
+	/**
33
+	 * @var EE_Ticket $ticket
34
+	 */
35
+	private $ticket;
36
+
37
+	/**
38
+	 * @var EE_Line_Item $ticket_line_item
39
+	 */
40
+	private $ticket_line_item;
41
+
42
+	/**
43
+	 * @var int $reg_count
44
+	 */
45
+	private $reg_count;
46
+
47
+	/**
48
+	 * @var int $reg_group_size
49
+	 */
50
+	private $reg_group_size;
51
+
52
+	/**
53
+	 * @var string $reg_status
54
+	 */
55
+	private $reg_status;
56
+
57
+	/**
58
+	 * @var EE_Registration $registration
59
+	 */
60
+	protected $registration;
61
+
62
+
63
+	/**
64
+	 * CreateRegistrationCommand constructor.
65
+	 *
66
+	 * @param EE_Transaction $transaction
67
+	 * @param EE_Line_Item   $ticket_line_item
68
+	 * @param int            $reg_count
69
+	 * @param int            $reg_group_size
70
+	 * @param string         $reg_status
71
+	 * @throws InvalidEntityException
72
+	 */
73
+	public function __construct(
74
+		EE_Transaction $transaction,
75
+		EE_Line_Item $ticket_line_item,
76
+		$reg_count = 1,
77
+		$reg_group_size = 0,
78
+		$reg_status = EEM_Registration::status_id_incomplete
79
+	) {
80
+		// grab the related ticket object for this line_item
81
+		$this->ticket = $ticket_line_item->ticket();
82
+		if (! $this->ticket instanceof EE_Ticket) {
83
+			throw new InvalidEntityException(
84
+				is_object($this->ticket) ? get_class($this->ticket) : gettype($this->ticket),
85
+				'EE_Ticket',
86
+				sprintf(
87
+					__('Line item %s did not contain a valid ticket', 'event_espresso'),
88
+					$ticket_line_item->ID()
89
+				)
90
+			);
91
+		}
92
+		$this->transaction = $transaction;
93
+		$this->ticket_line_item = $ticket_line_item;
94
+		$this->reg_count = absint($reg_count);
95
+		$this->reg_group_size = absint($reg_group_size);
96
+		$this->reg_status = $reg_status;
97
+	}
98
+
99
+
100
+	/**
101
+	 * @return \EventEspresso\core\domain\services\capabilities\CapCheckInterface
102
+	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
103
+	 */
104
+	public function getCapCheck()
105
+	{
106
+		if (! $this->cap_check instanceof CapCheckInterface) {
107
+			return new CapCheck('ee_edit_registrations', 'create_new_registration');
108
+		}
109
+		return $this->cap_check;
110
+	}
111
+
112
+
113
+	/**
114
+	 * @return EE_Transaction
115
+	 */
116
+	public function transaction()
117
+	{
118
+		return $this->transaction;
119
+	}
120
+
121
+
122
+	/**
123
+	 * @return EE_Ticket
124
+	 */
125
+	public function ticket()
126
+	{
127
+		return $this->ticket;
128
+	}
129
+
130
+
131
+	/**
132
+	 * @return EE_Line_Item
133
+	 */
134
+	public function ticketLineItem()
135
+	{
136
+		return $this->ticket_line_item;
137
+	}
138
+
139
+
140
+	/**
141
+	 * @return int
142
+	 */
143
+	public function regCount()
144
+	{
145
+		return $this->reg_count;
146
+	}
147
+
148
+
149
+	/**
150
+	 * @return int
151
+	 */
152
+	public function regGroupSize()
153
+	{
154
+		return $this->reg_group_size;
155
+	}
156
+
157
+
158
+	/**
159
+	 * @return string
160
+	 */
161
+	public function regStatus()
162
+	{
163
+		return $this->reg_status;
164
+	}
165
+
166
+
167
+	/**
168
+	 * @return EE_Registration
169
+	 */
170
+	public function registration()
171
+	{
172
+		return $this->registration;
173
+	}
174 174
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -79,7 +79,7 @@  discard block
 block discarded – undo
79 79
     ) {
80 80
         // grab the related ticket object for this line_item
81 81
         $this->ticket = $ticket_line_item->ticket();
82
-        if (! $this->ticket instanceof EE_Ticket) {
82
+        if ( ! $this->ticket instanceof EE_Ticket) {
83 83
             throw new InvalidEntityException(
84 84
                 is_object($this->ticket) ? get_class($this->ticket) : gettype($this->ticket),
85 85
                 'EE_Ticket',
@@ -103,7 +103,7 @@  discard block
 block discarded – undo
103 103
      */
104 104
     public function getCapCheck()
105 105
     {
106
-        if (! $this->cap_check instanceof CapCheckInterface) {
106
+        if ( ! $this->cap_check instanceof CapCheckInterface) {
107 107
             return new CapCheck('ee_edit_registrations', 'create_new_registration');
108 108
         }
109 109
         return $this->cap_check;
Please login to merge, or discard this patch.
commands/registration/CancelRegistrationAndTicketLineItemCommandHandler.php 2 patches
Indentation   +34 added lines, -34 removed lines patch added patch discarded remove patch
@@ -19,38 +19,38 @@
 block discarded – undo
19 19
 {
20 20
 
21 21
 
22
-    /**
23
-     * @var CancelTicketLineItemService $cancel_ticket_line_item_service
24
-     */
25
-    private $cancel_ticket_line_item_service;
26
-
27
-
28
-    /**
29
-     * Command constructor
30
-     *
31
-     * @param CancelTicketLineItemService $cancel_ticket_line_item_service
32
-     */
33
-    public function __construct(CancelTicketLineItemService $cancel_ticket_line_item_service)
34
-    {
35
-        $this->cancel_ticket_line_item_service = $cancel_ticket_line_item_service;
36
-    }
37
-
38
-
39
-    /**
40
-     * @param \EventEspresso\core\services\commands\CommandInterface $command
41
-     * @return boolean
42
-     */
43
-    public function handle(CommandInterface $command)
44
-    {
45
-        /** @var CancelRegistrationAndTicketLineItemCommand $command */
46
-        if (! $command instanceof CancelRegistrationAndTicketLineItemCommand) {
47
-            throw new InvalidEntityException(get_class($command), 'CancelRegistrationAndTicketLineItemCommand');
48
-        }
49
-        $registration = $command->registration();
50
-        $this->cancel_ticket_line_item_service->forRegistration($registration);
51
-        // cancel original registration
52
-        $registration->set_status(\EEM_Registration::status_id_cancelled);
53
-        $registration->save();
54
-        return true;
55
-    }
22
+	/**
23
+	 * @var CancelTicketLineItemService $cancel_ticket_line_item_service
24
+	 */
25
+	private $cancel_ticket_line_item_service;
26
+
27
+
28
+	/**
29
+	 * Command constructor
30
+	 *
31
+	 * @param CancelTicketLineItemService $cancel_ticket_line_item_service
32
+	 */
33
+	public function __construct(CancelTicketLineItemService $cancel_ticket_line_item_service)
34
+	{
35
+		$this->cancel_ticket_line_item_service = $cancel_ticket_line_item_service;
36
+	}
37
+
38
+
39
+	/**
40
+	 * @param \EventEspresso\core\services\commands\CommandInterface $command
41
+	 * @return boolean
42
+	 */
43
+	public function handle(CommandInterface $command)
44
+	{
45
+		/** @var CancelRegistrationAndTicketLineItemCommand $command */
46
+		if (! $command instanceof CancelRegistrationAndTicketLineItemCommand) {
47
+			throw new InvalidEntityException(get_class($command), 'CancelRegistrationAndTicketLineItemCommand');
48
+		}
49
+		$registration = $command->registration();
50
+		$this->cancel_ticket_line_item_service->forRegistration($registration);
51
+		// cancel original registration
52
+		$registration->set_status(\EEM_Registration::status_id_cancelled);
53
+		$registration->save();
54
+		return true;
55
+	}
56 56
 }
Please login to merge, or discard this patch.
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@
 block discarded – undo
60 60
     public function handle(CommandInterface $command)
61 61
     {
62 62
         /** @var CancelRegistrationAndTicketLineItemCommand $command */
63
-        if (! $command instanceof CancelRegistrationAndTicketLineItemCommand) {
63
+        if ( ! $command instanceof CancelRegistrationAndTicketLineItemCommand) {
64 64
             throw new InvalidEntityException(get_class($command), 'CancelRegistrationAndTicketLineItemCommand');
65 65
         }
66 66
         $registration = $command->registration();
Please login to merge, or discard this patch.
core/services/commands/CommandBus.php 2 patches
Indentation   +62 added lines, -62 removed lines patch added patch discarded remove patch
@@ -34,73 +34,73 @@
 block discarded – undo
34 34
 class CommandBus implements CommandBusInterface
35 35
 {
36 36
 
37
-    /**
38
-     * @type CommandHandlerManagerInterface $command_handler_manager
39
-     */
40
-    private $command_handler_manager;
37
+	/**
38
+	 * @type CommandHandlerManagerInterface $command_handler_manager
39
+	 */
40
+	private $command_handler_manager;
41 41
 
42
-    /**
43
-     * @type CommandBusMiddlewareInterface[] $command_bus_middleware
44
-     */
45
-    private $command_bus_middleware;
42
+	/**
43
+	 * @type CommandBusMiddlewareInterface[] $command_bus_middleware
44
+	 */
45
+	private $command_bus_middleware;
46 46
 
47 47
 
48
-    /**
49
-     * CommandBus constructor
50
-     *
51
-     * @param CommandHandlerManagerInterface  $command_handler_manager
52
-     * @param CommandBusMiddlewareInterface[] $command_bus_middleware
53
-     */
54
-    public function __construct(
55
-        CommandHandlerManagerInterface $command_handler_manager,
56
-        array $command_bus_middleware = array()
57
-    ) {
58
-        $this->command_handler_manager = $command_handler_manager;
59
-        $this->command_bus_middleware = is_array($command_bus_middleware)
60
-            ? $command_bus_middleware
61
-            : array($command_bus_middleware);
62
-    }
48
+	/**
49
+	 * CommandBus constructor
50
+	 *
51
+	 * @param CommandHandlerManagerInterface  $command_handler_manager
52
+	 * @param CommandBusMiddlewareInterface[] $command_bus_middleware
53
+	 */
54
+	public function __construct(
55
+		CommandHandlerManagerInterface $command_handler_manager,
56
+		array $command_bus_middleware = array()
57
+	) {
58
+		$this->command_handler_manager = $command_handler_manager;
59
+		$this->command_bus_middleware = is_array($command_bus_middleware)
60
+			? $command_bus_middleware
61
+			: array($command_bus_middleware);
62
+	}
63 63
 
64 64
 
65
-    /**
66
-     * @return CommandHandlerManagerInterface
67
-     */
68
-    public function getCommandHandlerManager()
69
-    {
70
-        return $this->command_handler_manager;
71
-    }
65
+	/**
66
+	 * @return CommandHandlerManagerInterface
67
+	 */
68
+	public function getCommandHandlerManager()
69
+	{
70
+		return $this->command_handler_manager;
71
+	}
72 72
 
73 73
 
74
-    /**
75
-     * @param CommandInterface $command
76
-     * @return mixed
77
-     * @throws InvalidDataTypeException
78
-     * @throws InvalidCommandBusMiddlewareException
79
-     */
80
-    public function execute($command)
81
-    {
82
-        if (! $command instanceof CommandInterface) {
83
-            throw new InvalidDataTypeException(__METHOD__ . '( $command )', $command, 'CommandInterface');
84
-        }
85
-        // we're going to add the Command Handler as a callable
86
-        // that will get run at the end of our middleware stack
87
-        // can't pass $this to a Closure, so use a named variable
88
-        $command_bus = $this;
89
-        $middleware = function ($command) use ($command_bus) {
90
-            return $command_bus->getCommandHandlerManager()
91
-                               ->getCommandHandler($command, $command_bus)
92
-                               ->handle($command);
93
-        };
94
-        // now build the rest of the middleware stack
95
-        while ($command_bus_middleware = array_pop($this->command_bus_middleware)) {
96
-            if (! $command_bus_middleware instanceof CommandBusMiddlewareInterface) {
97
-                throw new InvalidCommandBusMiddlewareException($command_bus_middleware);
98
-            }
99
-            $middleware = function ($command) use ($command_bus_middleware, $middleware) {
100
-                return $command_bus_middleware->handle($command, $middleware);
101
-            };
102
-        }
103
-        // and finally, pass the command into the stack and return the results
104
-        return $middleware($command);
105
-    }
74
+	/**
75
+	 * @param CommandInterface $command
76
+	 * @return mixed
77
+	 * @throws InvalidDataTypeException
78
+	 * @throws InvalidCommandBusMiddlewareException
79
+	 */
80
+	public function execute($command)
81
+	{
82
+		if (! $command instanceof CommandInterface) {
83
+			throw new InvalidDataTypeException(__METHOD__ . '( $command )', $command, 'CommandInterface');
84
+		}
85
+		// we're going to add the Command Handler as a callable
86
+		// that will get run at the end of our middleware stack
87
+		// can't pass $this to a Closure, so use a named variable
88
+		$command_bus = $this;
89
+		$middleware = function ($command) use ($command_bus) {
90
+			return $command_bus->getCommandHandlerManager()
91
+							   ->getCommandHandler($command, $command_bus)
92
+							   ->handle($command);
93
+		};
94
+		// now build the rest of the middleware stack
95
+		while ($command_bus_middleware = array_pop($this->command_bus_middleware)) {
96
+			if (! $command_bus_middleware instanceof CommandBusMiddlewareInterface) {
97
+				throw new InvalidCommandBusMiddlewareException($command_bus_middleware);
98
+			}
99
+			$middleware = function ($command) use ($command_bus_middleware, $middleware) {
100
+				return $command_bus_middleware->handle($command, $middleware);
101
+			};
102
+		}
103
+		// and finally, pass the command into the stack and return the results
104
+		return $middleware($command);
105
+	}
106 106
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -79,24 +79,24 @@
 block discarded – undo
79 79
      */
80 80
     public function execute($command)
81 81
     {
82
-        if (! $command instanceof CommandInterface) {
83
-            throw new InvalidDataTypeException(__METHOD__ . '( $command )', $command, 'CommandInterface');
82
+        if ( ! $command instanceof CommandInterface) {
83
+            throw new InvalidDataTypeException(__METHOD__.'( $command )', $command, 'CommandInterface');
84 84
         }
85 85
         // we're going to add the Command Handler as a callable
86 86
         // that will get run at the end of our middleware stack
87 87
         // can't pass $this to a Closure, so use a named variable
88 88
         $command_bus = $this;
89
-        $middleware = function ($command) use ($command_bus) {
89
+        $middleware = function($command) use ($command_bus) {
90 90
             return $command_bus->getCommandHandlerManager()
91 91
                                ->getCommandHandler($command, $command_bus)
92 92
                                ->handle($command);
93 93
         };
94 94
         // now build the rest of the middleware stack
95 95
         while ($command_bus_middleware = array_pop($this->command_bus_middleware)) {
96
-            if (! $command_bus_middleware instanceof CommandBusMiddlewareInterface) {
96
+            if ( ! $command_bus_middleware instanceof CommandBusMiddlewareInterface) {
97 97
                 throw new InvalidCommandBusMiddlewareException($command_bus_middleware);
98 98
             }
99
-            $middleware = function ($command) use ($command_bus_middleware, $middleware) {
99
+            $middleware = function($command) use ($command_bus_middleware, $middleware) {
100 100
                 return $command_bus_middleware->handle($command, $middleware);
101 101
             };
102 102
         }
Please login to merge, or discard this patch.
core/services/commands/transaction/CreateTransactionCommand.php 1 patch
Indentation   +47 added lines, -47 removed lines patch added patch discarded remove patch
@@ -20,60 +20,60 @@
 block discarded – undo
20 20
 class CreateTransactionCommand extends Command implements CommandRequiresCapCheckInterface
21 21
 {
22 22
 
23
-    /**
24
-     * @var EE_Checkout $checkout
25
-     */
26
-    protected $checkout;
23
+	/**
24
+	 * @var EE_Checkout $checkout
25
+	 */
26
+	protected $checkout;
27 27
 
28
-    /**
29
-     * @var array $transaction_details
30
-     */
31
-    protected $transaction_details;
28
+	/**
29
+	 * @var array $transaction_details
30
+	 */
31
+	protected $transaction_details;
32 32
 
33 33
 
34
-    /**
35
-     * CreateTransactionCommand constructor.
36
-     *
37
-     * @param EE_Checkout $checkout
38
-     * @param array       $transaction_details
39
-     */
40
-    public function __construct(EE_Checkout $checkout = null, array $transaction_details = array())
41
-    {
42
-        $this->checkout = $checkout;
43
-        $this->transaction_details = $transaction_details;
44
-    }
34
+	/**
35
+	 * CreateTransactionCommand constructor.
36
+	 *
37
+	 * @param EE_Checkout $checkout
38
+	 * @param array       $transaction_details
39
+	 */
40
+	public function __construct(EE_Checkout $checkout = null, array $transaction_details = array())
41
+	{
42
+		$this->checkout = $checkout;
43
+		$this->transaction_details = $transaction_details;
44
+	}
45 45
 
46 46
 
47
-    /**
48
-     * @return CapCheckInterface
49
-     * @throws InvalidDataTypeException
50
-     */
51
-    public function getCapCheck()
52
-    {
53
-        // need cap for non-AJAX admin requests
54
-        if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
55
-            // there's no specific caps for editing/creating transactions,
56
-            // so that's why we are using ee_edit_registrations
57
-            return new CapCheck('ee_edit_registrations', 'create_new_transaction');
58
-        }
59
-        return new PublicCapabilities('', 'create_new_transaction');
60
-    }
47
+	/**
48
+	 * @return CapCheckInterface
49
+	 * @throws InvalidDataTypeException
50
+	 */
51
+	public function getCapCheck()
52
+	{
53
+		// need cap for non-AJAX admin requests
54
+		if (! (defined('DOING_AJAX') && DOING_AJAX) && is_admin()) {
55
+			// there's no specific caps for editing/creating transactions,
56
+			// so that's why we are using ee_edit_registrations
57
+			return new CapCheck('ee_edit_registrations', 'create_new_transaction');
58
+		}
59
+		return new PublicCapabilities('', 'create_new_transaction');
60
+	}
61 61
 
62 62
 
63
-    /**
64
-     * @return EE_Checkout
65
-     */
66
-    public function checkout()
67
-    {
68
-        return $this->checkout;
69
-    }
63
+	/**
64
+	 * @return EE_Checkout
65
+	 */
66
+	public function checkout()
67
+	{
68
+		return $this->checkout;
69
+	}
70 70
 
71 71
 
72
-    /**
73
-     * @return array
74
-     */
75
-    public function transactionDetails()
76
-    {
77
-        return $this->transaction_details;
78
-    }
72
+	/**
73
+	 * @return array
74
+	 */
75
+	public function transactionDetails()
76
+	{
77
+		return $this->transaction_details;
78
+	}
79 79
 }
Please login to merge, or discard this patch.
core/services/commands/middleware/AddActionHook.php 1 patch
Indentation   +18 added lines, -18 removed lines patch added patch discarded remove patch
@@ -15,22 +15,22 @@
 block discarded – undo
15 15
 class AddActionHook implements CommandBusMiddlewareInterface
16 16
 {
17 17
 
18
-    /**
19
-     * @param CommandInterface $command
20
-     * @param Closure          $next
21
-     * @return mixed
22
-     */
23
-    public function handle(CommandInterface $command, Closure $next)
24
-    {
25
-        do_action(
26
-            'AHEE__EventEspresso_core_services_commands_middleware_AddActionHook__handle__before',
27
-            $command
28
-        );
29
-        $results = $next($command);
30
-        do_action(
31
-            'AHEE__EventEspresso_core_services_commands_middleware_AddActionHook__handle__after',
32
-            $command
33
-        );
34
-        return $results;
35
-    }
18
+	/**
19
+	 * @param CommandInterface $command
20
+	 * @param Closure          $next
21
+	 * @return mixed
22
+	 */
23
+	public function handle(CommandInterface $command, Closure $next)
24
+	{
25
+		do_action(
26
+			'AHEE__EventEspresso_core_services_commands_middleware_AddActionHook__handle__before',
27
+			$command
28
+		);
29
+		$results = $next($command);
30
+		do_action(
31
+			'AHEE__EventEspresso_core_services_commands_middleware_AddActionHook__handle__after',
32
+			$command
33
+		);
34
+		return $results;
35
+	}
36 36
 }
Please login to merge, or discard this patch.
core/services/commands/middleware/InvalidCommandBusMiddlewareException.php 1 patch
Indentation   +30 added lines, -30 removed lines patch added patch discarded remove patch
@@ -16,35 +16,35 @@
 block discarded – undo
16 16
 {
17 17
 
18 18
 
19
-    /**
20
-     * @access public
21
-     * @param  mixed     $command_bus_middleware_object
22
-     * @param  string    $message
23
-     * @param int        $code
24
-     * @param \Exception $previous
25
-     */
26
-    public function __construct($command_bus_middleware_object, $message = '', $code = 0, \Exception $previous = null)
27
-    {
28
-        $command_bus_middleware = is_object($command_bus_middleware_object)
29
-            ? get_class($command_bus_middleware_object)
30
-            : gettype($command_bus_middleware_object);
19
+	/**
20
+	 * @access public
21
+	 * @param  mixed     $command_bus_middleware_object
22
+	 * @param  string    $message
23
+	 * @param int        $code
24
+	 * @param \Exception $previous
25
+	 */
26
+	public function __construct($command_bus_middleware_object, $message = '', $code = 0, \Exception $previous = null)
27
+	{
28
+		$command_bus_middleware = is_object($command_bus_middleware_object)
29
+			? get_class($command_bus_middleware_object)
30
+			: gettype($command_bus_middleware_object);
31 31
 
32
-        if (empty($message)) {
33
-            $message = sprintf(
34
-                __(
35
-                    'The supplied Command Bus Middleware "%1$s" does not have a valid name. It should be in the following format: "{CommandName}Handler" ',
36
-                    'event_espresso'
37
-                ),
38
-                $command_bus_middleware
39
-            );
40
-        }
41
-        parent::__construct(
42
-            '$command_bus_middleware',
43
-            $command_bus_middleware,
44
-            'CommandBusMiddlewareInterface',
45
-            $message,
46
-            $code,
47
-            $previous
48
-        );
49
-    }
32
+		if (empty($message)) {
33
+			$message = sprintf(
34
+				__(
35
+					'The supplied Command Bus Middleware "%1$s" does not have a valid name. It should be in the following format: "{CommandName}Handler" ',
36
+					'event_espresso'
37
+				),
38
+				$command_bus_middleware
39
+			);
40
+		}
41
+		parent::__construct(
42
+			'$command_bus_middleware',
43
+			$command_bus_middleware,
44
+			'CommandBusMiddlewareInterface',
45
+			$message,
46
+			$code,
47
+			$previous
48
+		);
49
+	}
50 50
 }
Please login to merge, or discard this patch.
core/services/commands/middleware/CapChecker.php 1 patch
Indentation   +33 added lines, -33 removed lines patch added patch discarded remove patch
@@ -24,37 +24,37 @@
 block discarded – undo
24 24
 class CapChecker implements CommandBusMiddlewareInterface
25 25
 {
26 26
 
27
-    /**
28
-     * @type CapabilitiesCheckerInterface $capabilities_checker
29
-     */
30
-    private $capabilities_checker;
31
-
32
-
33
-    /**
34
-     * CapChecker constructor
35
-     *
36
-     * @param CapabilitiesCheckerInterface $capabilities_checker
37
-     */
38
-    public function __construct(CapabilitiesCheckerInterface $capabilities_checker)
39
-    {
40
-        $this->capabilities_checker = $capabilities_checker;
41
-    }
42
-
43
-
44
-    /**
45
-     * @param CommandInterface $command
46
-     * @param Closure          $next
47
-     * @return mixed
48
-     * @throws InvalidClassException
49
-     * @throws InsufficientPermissionsException
50
-     */
51
-    public function handle(CommandInterface $command, Closure $next)
52
-    {
53
-        if ($command instanceof CommandRequiresCapCheckInterface) {
54
-            $this->capabilities_checker->processCapCheck(
55
-                $command->getCapCheck()
56
-            );
57
-        }
58
-        return $next($command);
59
-    }
27
+	/**
28
+	 * @type CapabilitiesCheckerInterface $capabilities_checker
29
+	 */
30
+	private $capabilities_checker;
31
+
32
+
33
+	/**
34
+	 * CapChecker constructor
35
+	 *
36
+	 * @param CapabilitiesCheckerInterface $capabilities_checker
37
+	 */
38
+	public function __construct(CapabilitiesCheckerInterface $capabilities_checker)
39
+	{
40
+		$this->capabilities_checker = $capabilities_checker;
41
+	}
42
+
43
+
44
+	/**
45
+	 * @param CommandInterface $command
46
+	 * @param Closure          $next
47
+	 * @return mixed
48
+	 * @throws InvalidClassException
49
+	 * @throws InsufficientPermissionsException
50
+	 */
51
+	public function handle(CommandInterface $command, Closure $next)
52
+	{
53
+		if ($command instanceof CommandRequiresCapCheckInterface) {
54
+			$this->capabilities_checker->processCapCheck(
55
+				$command->getCapCheck()
56
+			);
57
+		}
58
+		return $next($command);
59
+	}
60 60
 }
Please login to merge, or discard this patch.