Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 12
0.00% covered (danger)
0.00%
0 / 2
CRAP
0.00% covered (danger)
0.00%
0 / 1
SiteClassificationController
0.00% covered (danger)
0.00%
0 / 12
0.00% covered (danger)
0.00%
0 / 2
12
0.00% covered (danger)
0.00%
0 / 1
 register_routes
0.00% covered (danger)
0.00%
0 / 9
0.00% covered (danger)
0.00%
0 / 1
2
 get
0.00% covered (danger)
0.00%
0 / 3
0.00% covered (danger)
0.00%
0 / 1
6
1<?php
2
3namespace NewfoldLabs\WP\Module\Onboarding\RestApi;
4
5use NewfoldLabs\WP\Module\Onboarding\Permissions;
6use NewfoldLabs\WP\Module\Data\SiteClassification\SiteClassification;
7
8/**
9 * Class SiteClassificationController
10 */
11class SiteClassificationController {
12
13    /**
14     * The namespace of this controller's route.
15     *
16     * @var string
17     */
18    protected $namespace = 'newfold-onboarding/v1';
19
20    /**
21     * The endpoint base
22     *
23     * @var string
24     */
25    protected $rest_base = '/site-classification';
26
27    /**
28     * Registers rest routes for SiteClassificationController class.
29     *
30     * @return void
31     */
32    public function register_routes() {
33        \register_rest_route(
34            $this->namespace,
35            $this->rest_base,
36            array(
37                'methods'             => \WP_REST_Server::READABLE,
38                'callback'            => array( $this, 'get' ),
39                'permission_callback' => array( Permissions::class, 'rest_is_authorized_admin' ),
40            )
41        );
42    }
43
44    /**
45     * Get site classification data.
46     *
47     * @return array
48     */
49    public function get() {
50        if ( ! class_exists( 'NewfoldLabs\WP\Module\Data\SiteClassification\SiteClassification' ) ) {
51            return array();
52        }
53        return SiteClassification::get();
54    }
55}