| Conditions | 1 |
| Paths | 1 |
| Total Lines | 90 |
| Code Lines | 72 |
| 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 |
||
| 133 | public function get_item_schema() { |
||
| 134 | $schema = array( |
||
| 135 | '$schema' => 'http://json-schema.org/draft-04/schema#', |
||
| 136 | 'title' => 'customer_download', |
||
| 137 | 'type' => 'object', |
||
| 138 | 'properties' => array( |
||
| 139 | 'download_id' => array( |
||
| 140 | 'description' => __( 'Download ID.', 'woocommerce' ), |
||
| 141 | 'type' => 'string', |
||
| 142 | 'context' => array( 'view' ), |
||
| 143 | 'readonly' => true, |
||
| 144 | ), |
||
| 145 | 'download_url' => array( |
||
| 146 | 'description' => __( 'Download file URL.', 'woocommerce' ), |
||
| 147 | 'type' => 'string', |
||
| 148 | 'context' => array( 'view' ), |
||
| 149 | 'readonly' => true, |
||
| 150 | ), |
||
| 151 | 'product_id' => array( |
||
| 152 | 'description' => __( 'Downloadable product ID.', 'woocommerce' ), |
||
| 153 | 'type' => 'integer', |
||
| 154 | 'context' => array( 'view' ), |
||
| 155 | 'readonly' => true, |
||
| 156 | ), |
||
| 157 | 'product_name' => array( |
||
| 158 | 'description' => __( 'Product name.', 'woocommerce' ), |
||
| 159 | 'type' => 'string', |
||
| 160 | 'context' => array( 'view' ), |
||
| 161 | 'readonly' => true, |
||
| 162 | ), |
||
| 163 | 'download_name' => array( |
||
| 164 | 'description' => __( 'Downloadable file name.', 'woocommerce' ), |
||
| 165 | 'type' => 'string', |
||
| 166 | 'context' => array( 'view' ), |
||
| 167 | 'readonly' => true, |
||
| 168 | ), |
||
| 169 | 'order_id' => array( |
||
| 170 | 'description' => __( 'Order ID.', 'woocommerce' ), |
||
| 171 | 'type' => 'integer', |
||
| 172 | 'context' => array( 'view' ), |
||
| 173 | 'readonly' => true, |
||
| 174 | ), |
||
| 175 | 'order_key' => array( |
||
| 176 | 'description' => __( 'Order key.', 'woocommerce' ), |
||
| 177 | 'type' => 'string', |
||
| 178 | 'context' => array( 'view' ), |
||
| 179 | 'readonly' => true, |
||
| 180 | ), |
||
| 181 | 'downloads_remaining' => array( |
||
| 182 | 'description' => __( 'Number of downloads remaining.', 'woocommerce' ), |
||
| 183 | 'type' => 'string', |
||
| 184 | 'context' => array( 'view' ), |
||
| 185 | 'readonly' => true, |
||
| 186 | ), |
||
| 187 | 'access_expires' => array( |
||
| 188 | 'description' => __( "The date when download access expires, in the site's timezone.", 'woocommerce' ), |
||
| 189 | 'type' => 'string', |
||
| 190 | 'context' => array( 'view' ), |
||
| 191 | 'readonly' => true, |
||
| 192 | ), |
||
| 193 | 'access_expires_gmt' => array( |
||
| 194 | 'description' => __( 'The date when download access expires, as GMT.', 'woocommerce' ), |
||
| 195 | 'type' => 'string', |
||
| 196 | 'context' => array( 'view' ), |
||
| 197 | 'readonly' => true, |
||
| 198 | ), |
||
| 199 | 'file' => array( |
||
| 200 | 'description' => __( 'File details.', 'woocommerce' ), |
||
| 201 | 'type' => 'object', |
||
| 202 | 'context' => array( 'view' ), |
||
| 203 | 'readonly' => true, |
||
| 204 | 'properties' => array( |
||
| 205 | 'name' => array( |
||
| 206 | 'description' => __( 'File name.', 'woocommerce' ), |
||
| 207 | 'type' => 'string', |
||
| 208 | 'context' => array( 'view' ), |
||
| 209 | 'readonly' => true, |
||
| 210 | ), |
||
| 211 | 'file' => array( |
||
| 212 | 'description' => __( 'File URL.', 'woocommerce' ), |
||
| 213 | 'type' => 'string', |
||
| 214 | 'context' => array( 'view' ), |
||
| 215 | 'readonly' => true, |
||
| 216 | ), |
||
| 217 | ), |
||
| 218 | ), |
||
| 219 | ), |
||
| 220 | ); |
||
| 221 | |||
| 222 | return $this->add_additional_fields_schema( $schema ); |
||
| 223 | } |
||
| 236 |