@@ -52,7 +52,7 @@ discard block |
||
52 | 52 | */ |
53 | 53 | final public function __invoke(): void { |
54 | 54 | $args = func_get_args(); |
55 | - $this->handle( $args ); |
|
55 | + $this->handle($args); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
@@ -61,8 +61,8 @@ discard block |
||
61 | 61 | * @param \PinkCrab\Loader\Hook_Loader $loader |
62 | 62 | * @return void |
63 | 63 | */ |
64 | - final public function register( Hook_Loader $loader ): void { |
|
65 | - $loader->action( $this->hook, $this ); |
|
64 | + final public function register(Hook_Loader $loader): void { |
|
65 | + $loader->action($this->hook, $this); |
|
66 | 66 | } |
67 | 67 | |
68 | 68 | /** |
@@ -71,6 +71,6 @@ discard block |
||
71 | 71 | * @param mixed[] $args |
72 | 72 | * @return void |
73 | 73 | */ |
74 | - abstract protected function handle( array $args): void; |
|
74 | + abstract protected function handle(array $args): void; |
|
75 | 75 | |
76 | 76 | } |
@@ -30,5 +30,5 @@ |
||
30 | 30 | interface Listener { |
31 | 31 | public function __invoke(): void; |
32 | 32 | public function get_hook(): string; |
33 | - public function register( Hook_Loader $loader ): void; |
|
33 | + public function register(Hook_Loader $loader): void; |
|
34 | 34 | } |
@@ -57,21 +57,21 @@ discard block |
||
57 | 57 | * @param Event $event |
58 | 58 | * @return int|null |
59 | 59 | */ |
60 | - public function dispatch( Event $event) : ?int; |
|
60 | + public function dispatch(Event $event) : ?int; |
|
61 | 61 | |
62 | 62 | /** |
63 | 63 | * Cancel next occurrence of Event |
64 | 64 | * |
65 | 65 | * @param Event $event |
66 | 66 | */ |
67 | - public function cancel_next( Event $event): void; |
|
67 | + public function cancel_next(Event $event): void; |
|
68 | 68 | |
69 | 69 | /** |
70 | 70 | * Cancel all occurrences of Event |
71 | 71 | * |
72 | 72 | * @param Event $event |
73 | 73 | */ |
74 | - public function cancel_all( Event $event): void; |
|
74 | + public function cancel_all(Event $event): void; |
|
75 | 75 | |
76 | 76 | /** |
77 | 77 | * Get next occurrence of Event |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | * @param Event $event |
80 | 80 | * @return DateTimeImmutable|null |
81 | 81 | */ |
82 | - public function find_next( Event $event): ?DateTimeImmutable; |
|
82 | + public function find_next(Event $event): ?DateTimeImmutable; |
|
83 | 83 | |
84 | 84 | /** |
85 | 85 | * Get all occurrences of Event |
@@ -87,7 +87,7 @@ discard block |
||
87 | 87 | * @param Event $event |
88 | 88 | * @return DateTimeImmutable[] |
89 | 89 | */ |
90 | - public function find_all( Event $event): array; |
|
90 | + public function find_all(Event $event): array; |
|
91 | 91 | |
92 | 92 | |
93 | 93 | /** |
@@ -96,6 +96,6 @@ discard block |
||
96 | 96 | * @param Event $event |
97 | 97 | * @return bool |
98 | 98 | */ |
99 | - public function is_scheduled( Event $event): bool; |
|
99 | + public function is_scheduled(Event $event): bool; |
|
100 | 100 | |
101 | 101 | } |
@@ -38,8 +38,8 @@ discard block |
||
38 | 38 | * @param bool $next_only |
39 | 39 | * @return void |
40 | 40 | */ |
41 | - public function cancel( Event $event, bool $next_only = false ): void { |
|
42 | - if ( $next_only ) { |
|
41 | + public function cancel(Event $event, bool $next_only = false): void { |
|
42 | + if ($next_only) { |
|
43 | 43 | \as_unschedule_action( |
44 | 44 | $event->get_hook(), |
45 | 45 | $event->get_data() ?? array(), |
@@ -61,15 +61,15 @@ discard block |
||
61 | 61 | * @param Event $event |
62 | 62 | * @return DateTimeImmutable|null |
63 | 63 | */ |
64 | - public function find_next( Event $event ): ?DateTimeImmutable { |
|
64 | + public function find_next(Event $event): ?DateTimeImmutable { |
|
65 | 65 | $next = as_next_scheduled_action( |
66 | 66 | $event->get_hook(), |
67 | 67 | $event->get_data() ?? array(), |
68 | 68 | $event->get_group() |
69 | 69 | ); |
70 | 70 | |
71 | - return is_int( $next ) |
|
72 | - ? ( DateTimeImmutable::createFromFormat( 'U', \strval( $next ), wp_timezone() ) ?: null ) //phpcs:ignore |
|
71 | + return is_int($next) |
|
72 | + ? (DateTimeImmutable::createFromFormat('U', \strval($next), wp_timezone()) ?: null) //phpcs:ignore |
|
73 | 73 | : null; |
74 | 74 | } |
75 | 75 | |
@@ -79,7 +79,7 @@ discard block |
||
79 | 79 | * @param Event $event |
80 | 80 | * @return array<int, DateTimeImmutable> |
81 | 81 | */ |
82 | - public function find_all( Event $event ): array { |
|
82 | + public function find_all(Event $event): array { |
|
83 | 83 | $events = as_get_scheduled_actions( |
84 | 84 | array( |
85 | 85 | 'hook' => $event->get_hook(), |
@@ -88,21 +88,21 @@ discard block |
||
88 | 88 | 'status' => \ActionScheduler_Store::STATUS_PENDING, |
89 | 89 | 'orderby' => 'date', |
90 | 90 | 'per_page' => -1, |
91 | - 'date' => DateTimeImmutable::createFromFormat( 'U', 'now', wp_timezone() ), |
|
91 | + 'date' => DateTimeImmutable::createFromFormat('U', 'now', wp_timezone()), |
|
92 | 92 | 'date_compare' => '>', |
93 | 93 | ) |
94 | 94 | ); |
95 | 95 | |
96 | 96 | return array_reduce( |
97 | 97 | $events, |
98 | - function ( array $carry, \ActionScheduler_Action $event ): array { |
|
98 | + function(array $carry, \ActionScheduler_Action $event): array { |
|
99 | 99 | /** @var ActionScheduler_SimpleSchedule */ |
100 | 100 | $schedule = $event->get_schedule(); |
101 | 101 | |
102 | 102 | // Get the date from schedule, if valid add to array. |
103 | 103 | $date = $schedule->get_date(); |
104 | - if ( $date instanceof \DateTime ) { |
|
105 | - $carry[] = DateTimeImmutable::createFromMutable( $date ); |
|
104 | + if ($date instanceof \DateTime) { |
|
105 | + $carry[] = DateTimeImmutable::createFromMutable($date); |
|
106 | 106 | } |
107 | 107 | return $carry; |
108 | 108 | }, |
@@ -116,7 +116,7 @@ discard block |
||
116 | 116 | * @param \PinkCrab\Queue\Event\Event $event |
117 | 117 | * @return bool |
118 | 118 | */ |
119 | - public function exists( Event $event ): bool { |
|
119 | + public function exists(Event $event): bool { |
|
120 | 120 | return as_has_scheduled_action( |
121 | 121 | $event->get_hook(), |
122 | 122 | $event->get_data() ?? array(), |
@@ -46,7 +46,7 @@ discard block |
||
46 | 46 | /** @var bool */ |
47 | 47 | private static $included = false; |
48 | 48 | |
49 | - public function __construct( Action_Scheduler_Dispatcher $dispatcher, Action_Scheduler_Queue_Manager $queue_manager ) { |
|
49 | + public function __construct(Action_Scheduler_Dispatcher $dispatcher, Action_Scheduler_Queue_Manager $queue_manager) { |
|
50 | 50 | $this->dispatcher = $dispatcher; |
51 | 51 | $this->queue_manager = $queue_manager; |
52 | 52 | } |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | public function setup(): void { |
74 | 74 | |
75 | 75 | // If the lib has already been included, bail. |
76 | - if ( self::$included ) { |
|
76 | + if (self::$included) { |
|
77 | 77 | return; |
78 | 78 | } |
79 | 79 | |
@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | $path = join( |
82 | 82 | \DIRECTORY_SEPARATOR, |
83 | 83 | array( |
84 | - dirname( __FILE__, 4 ), |
|
84 | + dirname(__FILE__, 4), |
|
85 | 85 | 'lib', |
86 | 86 | 'action-scheduler', |
87 | 87 | 'action-scheduler.php', |
@@ -89,11 +89,11 @@ discard block |
||
89 | 89 | ); |
90 | 90 | |
91 | 91 | // Filter the path to the action-scheduler path. |
92 | - $path = apply_filters( 'pinkcrab_queue_action_scheduler_path', $path ); |
|
92 | + $path = apply_filters('pinkcrab_queue_action_scheduler_path', $path); |
|
93 | 93 | |
94 | 94 | // Check if the file exists. |
95 | - if ( ! file_exists( $path ) ) { |
|
96 | - throw new \RuntimeException( 'Action Scheduler is not installed.' ); |
|
95 | + if ( ! file_exists($path)) { |
|
96 | + throw new \RuntimeException('Action Scheduler is not installed.'); |
|
97 | 97 | } |
98 | 98 | |
99 | 99 | // Include the Action Scheduler plugin. |
@@ -128,9 +128,9 @@ discard block |
||
128 | 128 | * |
129 | 129 | * @param Event $event |
130 | 130 | */ |
131 | - public function dispatch( Event $event ): ?int { |
|
132 | - $result = $this->dispatcher->dispatch( $event ); |
|
133 | - return \is_int( $result ) ? $result : null; |
|
131 | + public function dispatch(Event $event): ?int { |
|
132 | + $result = $this->dispatcher->dispatch($event); |
|
133 | + return \is_int($result) ? $result : null; |
|
134 | 134 | } |
135 | 135 | |
136 | 136 | /** |
@@ -138,8 +138,8 @@ discard block |
||
138 | 138 | * |
139 | 139 | * @param Event $event |
140 | 140 | */ |
141 | - public function cancel_next( Event $event ): void { |
|
142 | - $this->queue_manager->cancel( $event, true ); |
|
141 | + public function cancel_next(Event $event): void { |
|
142 | + $this->queue_manager->cancel($event, true); |
|
143 | 143 | } |
144 | 144 | |
145 | 145 | /** |
@@ -147,8 +147,8 @@ discard block |
||
147 | 147 | * |
148 | 148 | * @param Event $event |
149 | 149 | */ |
150 | - public function cancel_all( Event $event ): void { |
|
151 | - $this->queue_manager->cancel( $event, false ); |
|
150 | + public function cancel_all(Event $event): void { |
|
151 | + $this->queue_manager->cancel($event, false); |
|
152 | 152 | } |
153 | 153 | |
154 | 154 | /** |
@@ -157,8 +157,8 @@ discard block |
||
157 | 157 | * @param Event $event |
158 | 158 | * @return DateTimeImmutable|null |
159 | 159 | */ |
160 | - public function find_next( Event $event ): ?DateTimeImmutable { |
|
161 | - return $this->queue_manager->find_next( $event ); |
|
160 | + public function find_next(Event $event): ?DateTimeImmutable { |
|
161 | + return $this->queue_manager->find_next($event); |
|
162 | 162 | } |
163 | 163 | |
164 | 164 | /** |
@@ -167,8 +167,8 @@ discard block |
||
167 | 167 | * @param Event $event |
168 | 168 | * @return DateTimeImmutable[] |
169 | 169 | */ |
170 | - public function find_all( Event $event ): array { |
|
171 | - return $this->queue_manager->find_all( $event ); |
|
170 | + public function find_all(Event $event): array { |
|
171 | + return $this->queue_manager->find_all($event); |
|
172 | 172 | } |
173 | 173 | |
174 | 174 | |
@@ -178,7 +178,7 @@ discard block |
||
178 | 178 | * @param Event $event |
179 | 179 | * @return bool |
180 | 180 | */ |
181 | - public function is_scheduled( Event $event ): bool { |
|
182 | - return $this->queue_manager->exists( $event ); |
|
181 | + public function is_scheduled(Event $event): bool { |
|
182 | + return $this->queue_manager->exists($event); |
|
183 | 183 | } |
184 | 184 | } |
@@ -43,11 +43,11 @@ discard block |
||
43 | 43 | * @param Queue $queue_driver |
44 | 44 | * @return self |
45 | 45 | */ |
46 | - public function set_queue_driver( Queue $queue_driver ): self { |
|
46 | + public function set_queue_driver(Queue $queue_driver): self { |
|
47 | 47 | $this->queue_driver = $queue_driver; |
48 | 48 | |
49 | 49 | // Init the queue driver. |
50 | - add_action( 'init', array( $this, 'init_driver' ), -1 ); |
|
50 | + add_action('init', array($this, 'init_driver'), -1); |
|
51 | 51 | |
52 | 52 | return $this; |
53 | 53 | } |
@@ -82,7 +82,7 @@ discard block |
||
82 | 82 | */ |
83 | 83 | private function verify_queue_driver(): void { |
84 | 84 | // If the queue driver is not set, default to the Action Scheduler Driver. |
85 | - if ( ! $this->queue_driver instanceof Queue ) { |
|
85 | + if ( ! $this->queue_driver instanceof Queue) { |
|
86 | 86 | $this->queue_driver = Action_Scheduler_Driver::get_instance(); |
87 | 87 | } |
88 | 88 | } |
@@ -95,7 +95,7 @@ discard block |
||
95 | 95 | * @pram DI_Container $container |
96 | 96 | * @return void |
97 | 97 | */ |
98 | - public function pre_boot( App_Config $config, Hook_Loader $loader, DI_Container $container ): void { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceBeforeLastUsed, Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceAfterLastUsed |
|
98 | + public function pre_boot(App_Config $config, Hook_Loader $loader, DI_Container $container): void { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceBeforeLastUsed, Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceAfterLastUsed |
|
99 | 99 | |
100 | 100 | $this->verify_queue_driver(); |
101 | 101 | |
@@ -106,7 +106,7 @@ discard block |
||
106 | 106 | $container->addRule( |
107 | 107 | '*', |
108 | 108 | array( |
109 | - 'substitutions' => array( Queue::class => $this->queue_driver ), |
|
109 | + 'substitutions' => array(Queue::class => $this->queue_driver), |
|
110 | 110 | ) |
111 | 111 | ); |
112 | 112 | |
@@ -115,17 +115,17 @@ discard block |
||
115 | 115 | Listener::class, |
116 | 116 | array( |
117 | 117 | 'call' => array( |
118 | - array( 'register', array( $loader ) ), |
|
118 | + array('register', array($loader)), |
|
119 | 119 | ), |
120 | 120 | ) |
121 | 121 | ); |
122 | 122 | } |
123 | 123 | |
124 | 124 | /** @inheritDoc */ |
125 | - public function pre_register( App_Config $config, Hook_Loader $loader, DI_Container $container ): void {} // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceBeforeLastUsed |
|
125 | + public function pre_register(App_Config $config, Hook_Loader $loader, DI_Container $container): void {} // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceBeforeLastUsed |
|
126 | 126 | |
127 | 127 | /** @inheritDoc */ |
128 | - public function post_register( App_Config $config, Hook_Loader $loader, DI_Container $container ): void { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceBeforeLastUsed, Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceAfterLastUsed |
|
128 | + public function post_register(App_Config $config, Hook_Loader $loader, DI_Container $container): void { // phpcs:ignore Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceBeforeLastUsed, Generic.CodeAnalysis.UnusedFunctionParameter.FoundInImplementedInterfaceAfterLastUsed |
|
129 | 129 | // If the queue driver is not set, default to the Action Scheduler Driver. |
130 | 130 | $this->verify_queue_driver(); |
131 | 131 |
@@ -37,14 +37,14 @@ discard block |
||
37 | 37 | * @return Queue_Service |
38 | 38 | */ |
39 | 39 | public static function service(): Queue_Service { |
40 | - if ( self::$instance === null ) { |
|
40 | + if (self::$instance === null) { |
|
41 | 41 | /** @var Queue_Service|null */ |
42 | - $service = App::make( Queue_Service::class ); |
|
42 | + $service = App::make(Queue_Service::class); |
|
43 | 43 | self::$instance = $service; |
44 | 44 | } |
45 | 45 | |
46 | 46 | // If we still dont have an instance, throw an exception. |
47 | - if ( self::$instance === null ) { |
|
47 | + if (self::$instance === null) { |
|
48 | 48 | return self::service(); |
49 | 49 | } |
50 | 50 | |
@@ -57,8 +57,8 @@ discard block |
||
57 | 57 | * @param Event $event |
58 | 58 | * @return int|null |
59 | 59 | */ |
60 | - public static function dispatch( Event $event ): ?int { |
|
61 | - return self::service()->dispatch( $event ); |
|
60 | + public static function dispatch(Event $event): ?int { |
|
61 | + return self::service()->dispatch($event); |
|
62 | 62 | } |
63 | 63 | |
64 | 64 | /** |
@@ -67,8 +67,8 @@ discard block |
||
67 | 67 | * @param Event $event |
68 | 68 | * @return void |
69 | 69 | */ |
70 | - public static function cancel_next( Event $event ): void { |
|
71 | - self::service()->cancel_next( $event ); |
|
70 | + public static function cancel_next(Event $event): void { |
|
71 | + self::service()->cancel_next($event); |
|
72 | 72 | } |
73 | 73 | |
74 | 74 | /** |
@@ -77,8 +77,8 @@ discard block |
||
77 | 77 | * @param Event $event |
78 | 78 | * @return void |
79 | 79 | */ |
80 | - public static function cancel_all( Event $event ): void { |
|
81 | - self::service()->cancel_all( $event ); |
|
80 | + public static function cancel_all(Event $event): void { |
|
81 | + self::service()->cancel_all($event); |
|
82 | 82 | } |
83 | 83 | |
84 | 84 | /** |
@@ -87,8 +87,8 @@ discard block |
||
87 | 87 | * @param Event $event |
88 | 88 | * @return ?DateTimeImmutable |
89 | 89 | */ |
90 | - public static function next( Event $event ): ?DateTimeImmutable { |
|
91 | - return self::service()->next( $event ); |
|
90 | + public static function next(Event $event): ?DateTimeImmutable { |
|
91 | + return self::service()->next($event); |
|
92 | 92 | } |
93 | 93 | |
94 | 94 | /** |
@@ -97,8 +97,8 @@ discard block |
||
97 | 97 | * @param Event $event |
98 | 98 | * @return array<int, DateTimeImmutable> |
99 | 99 | */ |
100 | - public static function all( Event $event ): array { |
|
101 | - return self::service()->all( $event ); |
|
100 | + public static function all(Event $event): array { |
|
101 | + return self::service()->all($event); |
|
102 | 102 | } |
103 | 103 | |
104 | 104 | /** |
@@ -107,8 +107,8 @@ discard block |
||
107 | 107 | * @param Event $event |
108 | 108 | * @return bool |
109 | 109 | */ |
110 | - public static function exists( Event $event ): bool { |
|
111 | - return self::service()->exists( $event ); |
|
110 | + public static function exists(Event $event): bool { |
|
111 | + return self::service()->exists($event); |
|
112 | 112 | } |
113 | 113 | |
114 | 114 | } |
@@ -33,7 +33,7 @@ discard block |
||
33 | 33 | |
34 | 34 | private Queue $queue; |
35 | 35 | |
36 | - public function __construct( Queue $queue ) { |
|
36 | + public function __construct(Queue $queue) { |
|
37 | 37 | $this->queue = $queue; |
38 | 38 | } |
39 | 39 | |
@@ -42,8 +42,8 @@ discard block |
||
42 | 42 | * |
43 | 43 | * @param Event $event |
44 | 44 | */ |
45 | - public function dispatch( Event $event ): ?int { |
|
46 | - return $this->queue->dispatch( $event ); |
|
45 | + public function dispatch(Event $event): ?int { |
|
46 | + return $this->queue->dispatch($event); |
|
47 | 47 | } |
48 | 48 | |
49 | 49 | /** |
@@ -51,8 +51,8 @@ discard block |
||
51 | 51 | * |
52 | 52 | * @param Event $event |
53 | 53 | */ |
54 | - public function cancel_next( Event $event ): void { |
|
55 | - $this->queue->cancel_next( $event ); |
|
54 | + public function cancel_next(Event $event): void { |
|
55 | + $this->queue->cancel_next($event); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
@@ -60,8 +60,8 @@ discard block |
||
60 | 60 | * |
61 | 61 | * @param Event $event |
62 | 62 | */ |
63 | - public function cancel_all( Event $event ): void { |
|
64 | - $this->queue->cancel_all( $event ); |
|
63 | + public function cancel_all(Event $event): void { |
|
64 | + $this->queue->cancel_all($event); |
|
65 | 65 | } |
66 | 66 | |
67 | 67 | /** |
@@ -70,8 +70,8 @@ discard block |
||
70 | 70 | * @param Event $event |
71 | 71 | * @return DateTimeImmutable|null |
72 | 72 | */ |
73 | - public function next( Event $event ): ?DateTimeImmutable { |
|
74 | - return $this->queue->find_next( $event ); |
|
73 | + public function next(Event $event): ?DateTimeImmutable { |
|
74 | + return $this->queue->find_next($event); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | /** |
@@ -80,8 +80,8 @@ discard block |
||
80 | 80 | * @param Event $event |
81 | 81 | * @return DateTimeImmutable[] |
82 | 82 | */ |
83 | - public function all( Event $event ): array { |
|
84 | - return $this->queue->find_all( $event ); |
|
83 | + public function all(Event $event): array { |
|
84 | + return $this->queue->find_all($event); |
|
85 | 85 | } |
86 | 86 | |
87 | 87 | |
@@ -91,7 +91,7 @@ discard block |
||
91 | 91 | * @param Event $event |
92 | 92 | * @return bool |
93 | 93 | */ |
94 | - public function exists( Event $event ): bool { |
|
95 | - return $this->queue->is_scheduled( $event ); |
|
94 | + public function exists(Event $event): bool { |
|
95 | + return $this->queue->is_scheduled($event); |
|
96 | 96 | } |
97 | 97 | } |
@@ -39,10 +39,10 @@ discard block |
||
39 | 39 | * @param Event $event |
40 | 40 | * @return int|null Returns the event id. |
41 | 41 | */ |
42 | - public function dispatch( Event $event ): ?int { |
|
42 | + public function dispatch(Event $event): ?int { |
|
43 | 43 | // @phpstan-ignore-next-line |
44 | - $queue_id = \call_user_func( array( $this, $this->get_dispatch_type( $event ) ), $event ); |
|
45 | - return \is_int( $queue_id ) ? $queue_id : null; |
|
44 | + $queue_id = \call_user_func(array($this, $this->get_dispatch_type($event)), $event); |
|
45 | + return \is_int($queue_id) ? $queue_id : null; |
|
46 | 46 | } |
47 | 47 | |
48 | 48 | /** |
@@ -51,33 +51,33 @@ discard block |
||
51 | 51 | * @param Event $event |
52 | 52 | * @return string |
53 | 53 | */ |
54 | - private function get_dispatch_type( Event $event ): string { |
|
54 | + private function get_dispatch_type(Event $event): string { |
|
55 | 55 | // If the event is async or there is no delay or interval. |
56 | - if ( $event instanceof Async_Event |
|
57 | - || ( is_null( $event->delayed_until() ) && is_null( $event->interval() ) ) |
|
56 | + if ($event instanceof Async_Event |
|
57 | + || (is_null($event->delayed_until()) && is_null($event->interval())) |
|
58 | 58 | ) { |
59 | 59 | // Return async. |
60 | 60 | return 'dispatch_async'; |
61 | 61 | } |
62 | 62 | |
63 | 63 | // If the event is delayed or has no interval. |
64 | - if ( $event instanceof Delayed_Event |
|
65 | - || ( $event->delayed_until() instanceof DateTimeImmutable && is_null( $event->interval() ) ) |
|
64 | + if ($event instanceof Delayed_Event |
|
65 | + || ($event->delayed_until() instanceof DateTimeImmutable && is_null($event->interval())) |
|
66 | 66 | ) { |
67 | 67 | // Return delayed. |
68 | 68 | return 'dispatch_at'; |
69 | 69 | } |
70 | 70 | |
71 | 71 | // If the event is a recurring event and has an interval. |
72 | - if ( $event instanceof Recurring_Event |
|
73 | - || ( is_int( $event->interval() ) && $event->interval() > 0 ) |
|
72 | + if ($event instanceof Recurring_Event |
|
73 | + || (is_int($event->interval()) && $event->interval() > 0) |
|
74 | 74 | ) { |
75 | 75 | // Return recurring. |
76 | 76 | return 'dispatch_recurring'; |
77 | 77 | } |
78 | 78 | |
79 | 79 | // If we get to the end and none has passed, throw exception. |
80 | - throw new \Exception( 'Unable to determine dispatch type.' ); |
|
80 | + throw new \Exception('Unable to determine dispatch type.'); |
|
81 | 81 | } |
82 | 82 | |
83 | 83 | /** |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | * @param Event $event |
87 | 87 | * @return int Returns the event id. |
88 | 88 | */ |
89 | - private function dispatch_async( Event $event ): int { |
|
89 | + private function dispatch_async(Event $event): int { |
|
90 | 90 | return \as_enqueue_async_action( |
91 | 91 | $event->get_hook(), |
92 | 92 | $event->get_data() ?? array(), |
@@ -101,16 +101,16 @@ discard block |
||
101 | 101 | * @param Event $event |
102 | 102 | * @return int Returns the event id. |
103 | 103 | */ |
104 | - private function dispatch_at( Event $event ): int { |
|
105 | - if ( ! $event->delayed_until() instanceof DateTimeImmutable ) { |
|
106 | - throw new \InvalidArgumentException( 'Event must have a delayed_until date/time.' ); |
|
104 | + private function dispatch_at(Event $event): int { |
|
105 | + if ( ! $event->delayed_until() instanceof DateTimeImmutable) { |
|
106 | + throw new \InvalidArgumentException('Event must have a delayed_until date/time.'); |
|
107 | 107 | } |
108 | 108 | |
109 | 109 | /** @var DateTimeImmutable */ |
110 | 110 | $delayed_until = $event->delayed_until(); |
111 | 111 | |
112 | 112 | return as_schedule_single_action( |
113 | - (int) $delayed_until->setTimezone( wp_timezone() )->format( 'U' ), |
|
113 | + (int) $delayed_until->setTimezone(wp_timezone())->format('U'), |
|
114 | 114 | $event->get_hook(), |
115 | 115 | $event->get_data() ?? array(), |
116 | 116 | $event->get_group(), |
@@ -124,18 +124,18 @@ discard block |
||
124 | 124 | * @param Event $event |
125 | 125 | * @return int Returns the event id. |
126 | 126 | */ |
127 | - private function dispatch_recurring( Event $event ): int { |
|
128 | - if ( $event->interval() === null ) { |
|
129 | - throw new \InvalidArgumentException( 'Event must have an for it to be recurring.' ); |
|
127 | + private function dispatch_recurring(Event $event): int { |
|
128 | + if ($event->interval() === null) { |
|
129 | + throw new \InvalidArgumentException('Event must have an for it to be recurring.'); |
|
130 | 130 | } |
131 | 131 | |
132 | 132 | /** @var DateTimeImmutable */ |
133 | 133 | $delayed_until = $event->delayed_until() instanceof \DateTimeImmutable |
134 | - ? $event->delayed_until()->setTimezone( wp_timezone() ) |
|
135 | - : DateTimeImmutable::createFromFormat( 'U', '0', wp_timezone() ); |
|
134 | + ? $event->delayed_until()->setTimezone(wp_timezone()) |
|
135 | + : DateTimeImmutable::createFromFormat('U', '0', wp_timezone()); |
|
136 | 136 | |
137 | 137 | return as_schedule_recurring_action( |
138 | - (int) $delayed_until->format( 'U' ), |
|
138 | + (int) $delayed_until->format('U'), |
|
139 | 139 | $event->interval(), |
140 | 140 | $event->get_hook(), |
141 | 141 | $event->get_data() ?? array(), |