Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
50.00% covered (danger)
50.00%
3 / 6
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
WPCOM_JSON_API_Taxonomy_Endpoint
75.00% covered (warning)
75.00%
3 / 4
0.00% covered (danger)
0.00%
0 / 1
2.06
0.00% covered (danger)
0.00%
0 / 1
 __construct
75.00% covered (warning)
75.00%
3 / 4
0.00% covered (danger)
0.00%
0 / 1
2.06
1<?php // phpcs:ignore WordPress.Files.FileName.InvalidClassFileName
2
3if ( ! defined( 'ABSPATH' ) ) {
4    exit( 0 );
5}
6
7/**
8 * Taxonomy endpoint.
9 */
10abstract class WPCOM_JSON_API_Taxonomy_Endpoint extends WPCOM_JSON_API_Endpoint {
11
12    /**
13     * Category object format.
14     *
15     * @var array
16     */
17    public $category_object_format = array(
18        'ID'          => '(int) The category ID.',
19        'name'        => '(string) The name of the category.',
20        'slug'        => '(string) The slug of the category.',
21        'description' => '(string) The description of the category.',
22        'post_count'  => '(int) The number of posts using this category.',
23        'feed_url'    => '(string) The URL of the feed for this category.',
24        'parent'      => '(int) The parent ID for the category.',
25        'meta'        => '(object) Meta data',
26    );
27
28    /**
29     * Tag object format.
30     *
31     * @var array
32     */
33    public $tag_object_format = array(
34        'ID'          => '(int) The tag ID.',
35        'name'        => '(string) The name of the tag.',
36        'slug'        => '(string) The slug of the tag.',
37        'description' => '(string) The description of the tag.',
38        'post_count'  => '(int) The number of posts using this t.',
39        'meta'        => '(object) Meta data',
40    );
41
42    /**
43     * Constructor function.
44     *
45     * @param string|array|object $args - the arguments.
46     */
47    public function __construct( $args ) {
48        parent::__construct( $args );
49        if ( preg_match( '#/tags/#i', $this->path ) ) {
50            $this->response_format =& $this->tag_object_format;
51        } else {
52            $this->response_format =& $this->category_object_format;
53        }
54    }
55}