handlers[] = $handler; return $this; } /** * @param null|WP_Error|WP_User $user * * @return bool|JSON_Response|Redirection_Response|View_Response */ public function authenticate( $user ) { if ( empty( $this->handlers ) ) { return false; } $handler = $this->create_handler(); return $handler->authenticate( $user ); } /** * @return Login_Handler */ private function create_handler() { $first = array_shift( $this->handlers ); array_reduce( $this->handlers, function ( Login_Handler $current, Login_Handler $next ) { $current->then( $next ); return $next; }, $first ); return $first; } }