Conditions | 2 |
Paths | 2 |
Total Lines | 55 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
1 | <?php |
||
40 | public function __construct( Manager $connection ) { |
||
41 | $this->connection = $connection; |
||
42 | |||
43 | self::$user_permissions_error_msg = esc_html__( |
||
44 | 'You do not have the correct user permissions to perform this action. |
||
45 | Please contact your site admin if you think this is a mistake.', |
||
46 | 'jetpack' |
||
47 | ); |
||
48 | |||
49 | if ( ! $this->connection->is_active() ) { |
||
50 | // Register a site. |
||
51 | register_rest_route( |
||
52 | 'jetpack/v4', |
||
53 | '/verify_registration', |
||
54 | array( |
||
55 | 'methods' => WP_REST_Server::EDITABLE, |
||
56 | 'callback' => array( $this, 'verify_registration' ), |
||
57 | 'permission_callback' => '__return_true', |
||
58 | ) |
||
59 | ); |
||
60 | } |
||
61 | |||
62 | // Authorize a remote user. |
||
63 | register_rest_route( |
||
64 | 'jetpack/v4', |
||
65 | '/remote_authorize', |
||
66 | array( |
||
67 | 'methods' => WP_REST_Server::EDITABLE, |
||
68 | 'callback' => __CLASS__ . '::remote_authorize', |
||
69 | 'permission_callback' => '__return_true', |
||
70 | ) |
||
71 | ); |
||
72 | |||
73 | // Get current connection status of Jetpack. |
||
74 | register_rest_route( |
||
75 | 'jetpack/v4', |
||
76 | '/connection', |
||
77 | array( |
||
78 | 'methods' => WP_REST_Server::READABLE, |
||
79 | 'callback' => __CLASS__ . '::connection_status', |
||
80 | 'permission_callback' => '__return_true', |
||
81 | ) |
||
82 | ); |
||
83 | |||
84 | // Get list of plugins that use the Jetpack connection. |
||
85 | register_rest_route( |
||
86 | 'jetpack/v4', |
||
87 | '/connection/plugins', |
||
88 | array( |
||
89 | 'methods' => WP_REST_Server::READABLE, |
||
90 | 'callback' => array( $this, 'get_connection_plugins' ), |
||
91 | 'permission_callback' => __CLASS__ . '::activate_plugins_permission_check', |
||
92 | ) |
||
93 | ); |
||
94 | } |
||
95 | |||
207 |
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.