Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
75.00% covered (warning)
75.00%
6 / 8
50.00% covered (danger)
50.00%
2 / 4
CRAP
0.00% covered (danger)
0.00%
0 / 1
Type_Void
75.00% covered (warning)
75.00%
6 / 8
50.00% covered (danger)
50.00%
2 / 4
6.56
0.00% covered (danger)
0.00%
0 / 1
 parse
66.67% covered (warning)
66.67%
2 / 3
0.00% covered (danger)
0.00%
0 / 1
3.33
 __toString
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
1
 jsonSerialize
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 1
2
 schema
100.00% covered (success)
100.00%
3 / 3
100.00% covered (success)
100.00%
1 / 1
1
1<?php
2
3namespace Automattic\Jetpack\Schema\Types;
4
5use Automattic\Jetpack\Schema\Parser;
6use Automattic\Jetpack\Schema\Schema_Error;
7use Automattic\Jetpack\Schema\Utils;
8
9/**
10 * This schema represents no data whatsoever. It will always return null.
11 */
12class Type_Void implements Parser {
13
14    public function parse( $value, $_context ) {
15        if ( ! empty( $value ) && Utils::is_debug() ) {
16            throw new Schema_Error( 'Void type cannot have any data.', $value );
17        }
18        return null;
19    }
20    public function __toString() {
21        return 'void';
22    }
23
24    #[\ReturnTypeWillChange]
25    public function jsonSerialize() {
26        return $this->schema();
27    }
28
29    public function schema() {
30        return array(
31            'type' => (string) $this,
32        );
33    }
34}