original_string: public function rest_api_init() {
  		$register = [];
  		foreach ( [ 'GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'HEAD', 'OPTION' ] as $method ) {
  			$method_name = strtolower( "handle_{$method}" );
  			if ( ! method_exists( $this, $method_name ) ) {
  				continue;
  			}
  			$register[] = [
  				'methods' => $method,
  			    'callback' => [ $this, 'invoke' ],
  			    'args'     => $this->get_arguments( $method ),
  			    'permission_callback' => [ $this, 'permission_callback' ],
  			];
  		}
  		if ( ! $register ) {
  			throw new \Exception( sprintf( 'Class %s has no handler.', get_called_class() ), 500 );
  		} else {
  			register_rest_route( $this->namespace, $this->get_route(), $register );
  		}
  	}
code: public function rest_api_init() {
  		$register = [];
  		foreach ( [ 'GET', 'POST', 'PUT', 'PATCH', 'DELETE', 'HEAD', 'OPTION' ] as $method ) {
  			$method_name = strtolower( "handle_{$method}" );
  			if ( ! method_exists( $this, $method_name ) ) {
  				continue;
  			}
  			$register[] = [
  				'methods' => $method,
  			    'callback' => [ $this, 'invoke' ],
  			    'args'     => $this->get_arguments( $method ),
  			    'permission_callback' => [ $this, 'permission_callback' ],
  			];
  		}
  		if ( ! $register ) {
  			throw new \Exception( sprintf( 'Class %s has no handler.', get_called_class() ), 500 );
  		} else {
  			register_rest_route( $this->namespace, $this->get_route(), $register );
  		}
  	}
code_tokens: public function rest_api_init ( ) { $ register = [ ] ; foreach ( [ 'GET' , 'POST' , 'PUT' , 'PATCH' , 'DELETE' , 'HEAD' , 'OPTION' ] as $ method ) { $ method_name = strtolower ( "handle_{$method}" ) ; if ( ! method_exists ( $ this , $ method_name ) ) { continue ; } $ register [ ] = [ 'methods' => $ method , 'callback' => [ $ this , 'invoke' ] , 'args' => $ this -> get_arguments ( $ method ) , 'permission_callback' => [ $ this , 'permission_callback' ] , ] ; } if ( ! $ register ) { throw new \ Exception ( sprintf ( 'Class %s has no handler.' , get_called_class ( ) ) , 500 ) ; } else { register_rest_route ( $ this -> namespace , $ this -> get_route ( ) , $ register ) ; } }
docstring: Register rest endpoints
  
  @throws \Exception If no handler is set, throws error.
docstring_tokens: Register rest endpoints