| Conditions | 1 |
| Paths | 1 |
| Total Lines | 222 |
| Code Lines | 177 |
| 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 |
||
| 421 | public function get_item_schema() { |
||
| 422 | $schema = array( |
||
| 423 | '$schema' => 'http://json-schema.org/draft-04/schema#', |
||
| 424 | 'title' => $this->post_type, |
||
| 425 | 'type' => 'object', |
||
| 426 | 'properties' => array( |
||
| 427 | 'id' => array( |
||
| 428 | 'description' => __( 'Unique identifier for the resource.', 'woocommerce-rest-api' ), |
||
| 429 | 'type' => 'integer', |
||
| 430 | 'context' => array( 'view', 'edit' ), |
||
| 431 | 'readonly' => true, |
||
| 432 | ), |
||
| 433 | 'date_created' => array( |
||
| 434 | 'description' => __( "The date the order refund was created, in the site's timezone.", 'woocommerce-rest-api' ), |
||
| 435 | 'type' => 'date-time', |
||
| 436 | 'context' => array( 'view', 'edit' ), |
||
| 437 | 'readonly' => true, |
||
| 438 | ), |
||
| 439 | 'date_created_gmt' => array( |
||
| 440 | 'description' => __( 'The date the order refund was created, as GMT.', 'woocommerce-rest-api' ), |
||
| 441 | 'type' => 'date-time', |
||
| 442 | 'context' => array( 'view', 'edit' ), |
||
| 443 | 'readonly' => true, |
||
| 444 | ), |
||
| 445 | 'amount' => array( |
||
| 446 | 'description' => __( 'Refund amount.', 'woocommerce-rest-api' ), |
||
| 447 | 'type' => 'string', |
||
| 448 | 'context' => array( 'view', 'edit' ), |
||
| 449 | ), |
||
| 450 | 'reason' => array( |
||
| 451 | 'description' => __( 'Reason for refund.', 'woocommerce-rest-api' ), |
||
| 452 | 'type' => 'string', |
||
| 453 | 'context' => array( 'view', 'edit' ), |
||
| 454 | ), |
||
| 455 | 'refunded_by' => array( |
||
| 456 | 'description' => __( 'User ID of user who created the refund.', 'woocommerce-rest-api' ), |
||
| 457 | 'type' => 'integer', |
||
| 458 | 'context' => array( 'view', 'edit' ), |
||
| 459 | ), |
||
| 460 | 'refunded_payment' => array( |
||
| 461 | 'description' => __( 'If the payment was refunded via the API.', 'woocommerce-rest-api' ), |
||
| 462 | 'type' => 'boolean', |
||
| 463 | 'context' => array( 'view' ), |
||
| 464 | 'readonly' => true, |
||
| 465 | ), |
||
| 466 | 'meta_data' => array( |
||
| 467 | 'description' => __( 'Meta data.', 'woocommerce-rest-api' ), |
||
| 468 | 'type' => 'array', |
||
| 469 | 'context' => array( 'view', 'edit' ), |
||
| 470 | 'items' => array( |
||
| 471 | 'type' => 'object', |
||
| 472 | 'properties' => array( |
||
| 473 | 'id' => array( |
||
| 474 | 'description' => __( 'Meta ID.', 'woocommerce-rest-api' ), |
||
| 475 | 'type' => 'integer', |
||
| 476 | 'context' => array( 'view', 'edit' ), |
||
| 477 | 'readonly' => true, |
||
| 478 | ), |
||
| 479 | 'key' => array( |
||
| 480 | 'description' => __( 'Meta key.', 'woocommerce-rest-api' ), |
||
| 481 | 'type' => 'string', |
||
| 482 | 'context' => array( 'view', 'edit' ), |
||
| 483 | ), |
||
| 484 | 'value' => array( |
||
| 485 | 'description' => __( 'Meta value.', 'woocommerce-rest-api' ), |
||
| 486 | 'type' => 'mixed', |
||
| 487 | 'context' => array( 'view', 'edit' ), |
||
| 488 | ), |
||
| 489 | ), |
||
| 490 | ), |
||
| 491 | ), |
||
| 492 | 'line_items' => array( |
||
| 493 | 'description' => __( 'Line items data.', 'woocommerce-rest-api' ), |
||
| 494 | 'type' => 'array', |
||
| 495 | 'context' => array( 'view', 'edit' ), |
||
| 496 | 'readonly' => true, |
||
| 497 | 'items' => array( |
||
| 498 | 'type' => 'object', |
||
| 499 | 'properties' => array( |
||
| 500 | 'id' => array( |
||
| 501 | 'description' => __( 'Item ID.', 'woocommerce-rest-api' ), |
||
| 502 | 'type' => 'integer', |
||
| 503 | 'context' => array( 'view', 'edit' ), |
||
| 504 | 'readonly' => true, |
||
| 505 | ), |
||
| 506 | 'name' => array( |
||
| 507 | 'description' => __( 'Product name.', 'woocommerce-rest-api' ), |
||
| 508 | 'type' => 'mixed', |
||
| 509 | 'context' => array( 'view', 'edit' ), |
||
| 510 | 'readonly' => true, |
||
| 511 | ), |
||
| 512 | 'product_id' => array( |
||
| 513 | 'description' => __( 'Product ID.', 'woocommerce-rest-api' ), |
||
| 514 | 'type' => 'mixed', |
||
| 515 | 'context' => array( 'view', 'edit' ), |
||
| 516 | 'readonly' => true, |
||
| 517 | ), |
||
| 518 | 'variation_id' => array( |
||
| 519 | 'description' => __( 'Variation ID, if applicable.', 'woocommerce-rest-api' ), |
||
| 520 | 'type' => 'integer', |
||
| 521 | 'context' => array( 'view', 'edit' ), |
||
| 522 | 'readonly' => true, |
||
| 523 | ), |
||
| 524 | 'quantity' => array( |
||
| 525 | 'description' => __( 'Quantity ordered.', 'woocommerce-rest-api' ), |
||
| 526 | 'type' => 'integer', |
||
| 527 | 'context' => array( 'view', 'edit' ), |
||
| 528 | 'readonly' => true, |
||
| 529 | ), |
||
| 530 | 'tax_class' => array( |
||
| 531 | 'description' => __( 'Tax class of product.', 'woocommerce-rest-api' ), |
||
| 532 | 'type' => 'string', |
||
| 533 | 'context' => array( 'view', 'edit' ), |
||
| 534 | 'readonly' => true, |
||
| 535 | ), |
||
| 536 | 'subtotal' => array( |
||
| 537 | 'description' => __( 'Line subtotal (before discounts).', 'woocommerce-rest-api' ), |
||
| 538 | 'type' => 'string', |
||
| 539 | 'context' => array( 'view', 'edit' ), |
||
| 540 | 'readonly' => true, |
||
| 541 | ), |
||
| 542 | 'subtotal_tax' => array( |
||
| 543 | 'description' => __( 'Line subtotal tax (before discounts).', 'woocommerce-rest-api' ), |
||
| 544 | 'type' => 'string', |
||
| 545 | 'context' => array( 'view', 'edit' ), |
||
| 546 | 'readonly' => true, |
||
| 547 | ), |
||
| 548 | 'total' => array( |
||
| 549 | 'description' => __( 'Line total (after discounts).', 'woocommerce-rest-api' ), |
||
| 550 | 'type' => 'string', |
||
| 551 | 'context' => array( 'view', 'edit' ), |
||
| 552 | 'readonly' => true, |
||
| 553 | ), |
||
| 554 | 'total_tax' => array( |
||
| 555 | 'description' => __( 'Line total tax (after discounts).', 'woocommerce-rest-api' ), |
||
| 556 | 'type' => 'string', |
||
| 557 | 'context' => array( 'view', 'edit' ), |
||
| 558 | 'readonly' => true, |
||
| 559 | ), |
||
| 560 | 'taxes' => array( |
||
| 561 | 'description' => __( 'Line taxes.', 'woocommerce-rest-api' ), |
||
| 562 | 'type' => 'array', |
||
| 563 | 'context' => array( 'view', 'edit' ), |
||
| 564 | 'readonly' => true, |
||
| 565 | 'items' => array( |
||
| 566 | 'type' => 'object', |
||
| 567 | 'properties' => array( |
||
| 568 | 'id' => array( |
||
| 569 | 'description' => __( 'Tax rate ID.', 'woocommerce-rest-api' ), |
||
| 570 | 'type' => 'integer', |
||
| 571 | 'context' => array( 'view', 'edit' ), |
||
| 572 | 'readonly' => true, |
||
| 573 | ), |
||
| 574 | 'total' => array( |
||
| 575 | 'description' => __( 'Tax total.', 'woocommerce-rest-api' ), |
||
| 576 | 'type' => 'string', |
||
| 577 | 'context' => array( 'view', 'edit' ), |
||
| 578 | 'readonly' => true, |
||
| 579 | ), |
||
| 580 | 'subtotal' => array( |
||
| 581 | 'description' => __( 'Tax subtotal.', 'woocommerce-rest-api' ), |
||
| 582 | 'type' => 'string', |
||
| 583 | 'context' => array( 'view', 'edit' ), |
||
| 584 | 'readonly' => true, |
||
| 585 | ), |
||
| 586 | ), |
||
| 587 | ), |
||
| 588 | ), |
||
| 589 | 'meta_data' => array( |
||
| 590 | 'description' => __( 'Meta data.', 'woocommerce-rest-api' ), |
||
| 591 | 'type' => 'array', |
||
| 592 | 'context' => array( 'view', 'edit' ), |
||
| 593 | 'readonly' => true, |
||
| 594 | 'items' => array( |
||
| 595 | 'type' => 'object', |
||
| 596 | 'properties' => array( |
||
| 597 | 'id' => array( |
||
| 598 | 'description' => __( 'Meta ID.', 'woocommerce-rest-api' ), |
||
| 599 | 'type' => 'integer', |
||
| 600 | 'context' => array( 'view', 'edit' ), |
||
| 601 | 'readonly' => true, |
||
| 602 | ), |
||
| 603 | 'key' => array( |
||
| 604 | 'description' => __( 'Meta key.', 'woocommerce-rest-api' ), |
||
| 605 | 'type' => 'string', |
||
| 606 | 'context' => array( 'view', 'edit' ), |
||
| 607 | 'readonly' => true, |
||
| 608 | ), |
||
| 609 | 'value' => array( |
||
| 610 | 'description' => __( 'Meta value.', 'woocommerce-rest-api' ), |
||
| 611 | 'type' => 'mixed', |
||
| 612 | 'context' => array( 'view', 'edit' ), |
||
| 613 | 'readonly' => true, |
||
| 614 | ), |
||
| 615 | ), |
||
| 616 | ), |
||
| 617 | ), |
||
| 618 | 'sku' => array( |
||
| 619 | 'description' => __( 'Product SKU.', 'woocommerce-rest-api' ), |
||
| 620 | 'type' => 'string', |
||
| 621 | 'context' => array( 'view', 'edit' ), |
||
| 622 | 'readonly' => true, |
||
| 623 | ), |
||
| 624 | 'price' => array( |
||
| 625 | 'description' => __( 'Product price.', 'woocommerce-rest-api' ), |
||
| 626 | 'type' => 'number', |
||
| 627 | 'context' => array( 'view', 'edit' ), |
||
| 628 | 'readonly' => true, |
||
| 629 | ), |
||
| 630 | ), |
||
| 631 | ), |
||
| 632 | ), |
||
| 633 | 'api_refund' => array( |
||
| 634 | 'description' => __( 'When true, the payment gateway API is used to generate the refund.', 'woocommerce-rest-api' ), |
||
| 635 | 'type' => 'boolean', |
||
| 636 | 'context' => array( 'edit' ), |
||
| 637 | 'default' => true, |
||
| 638 | ), |
||
| 639 | ), |
||
| 640 | ); |
||
| 641 | |||
| 642 | return $this->add_additional_fields_schema( $schema ); |
||
| 643 | } |
||
| 666 |