Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
80.00% |
4 / 5 |
|
100.00% |
2 / 2 |
CRAP | |
100.00% |
1 / 1 |
| Reports_Page | |
100.00% |
4 / 4 |
|
100.00% |
2 / 2 |
4 | |
100.00% |
1 / 1 |
| __construct | |
100.00% |
3 / 3 |
|
100.00% |
1 / 1 |
3 | |||
| to_array | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * A reports page: the dashboard page that lists the records of one report, at `/reports/{path}`. |
| 4 | * |
| 5 | * @package automattic/jetpack-premium-analytics |
| 6 | */ |
| 7 | |
| 8 | namespace Automattic\Jetpack\PremiumAnalytics; |
| 9 | |
| 10 | require_once __DIR__ . '/class-single-report-page.php'; |
| 11 | |
| 12 | /** |
| 13 | * Describes one reports page registered with the dashboard. |
| 14 | * |
| 15 | * The record of a single-report page without the entity scope: sections, each with its |
| 16 | * controls and a layout of widgets. |
| 17 | * |
| 18 | * @since $$next-version$$ |
| 19 | */ |
| 20 | class Reports_Page extends Single_Report_Page { |
| 21 | |
| 22 | /** |
| 23 | * Record keys that scope a single-report page to one entity. |
| 24 | * |
| 25 | * @var string[] |
| 26 | */ |
| 27 | const ENTITY_SCOPE_KEYS = array( 'scope_param', 'id_pattern', 'reports_page' ); |
| 28 | |
| 29 | /** |
| 30 | * Constructor. |
| 31 | * |
| 32 | * @param string $dashboard_name Dashboard identifier. |
| 33 | * @param string $id Page identifier. |
| 34 | * @param array $args Page arguments. |
| 35 | */ |
| 36 | public function __construct( $dashboard_name, $id, $args = array() ) { |
| 37 | parent::__construct( $dashboard_name, $id, $args ); |
| 38 | |
| 39 | if ( ! is_array( $args ) || empty( $args['preferences_scope'] ) ) { |
| 40 | $this->preferences_scope = 'jetpack-premium-analytics/' . $this->path . '-report'; |
| 41 | } |
| 42 | } |
| 43 | |
| 44 | /** |
| 45 | * The record the client reads. |
| 46 | * |
| 47 | * @return array |
| 48 | */ |
| 49 | public function to_array() { |
| 50 | return array_diff_key( parent::to_array(), array_flip( self::ENTITY_SCOPE_KEYS ) ); |
| 51 | } |
| 52 | } |