@@ -15,105 +15,105 @@ |
||
15 | 15 | */ |
16 | 16 | class GetPaid_Meta_Data implements JsonSerializable { |
17 | 17 | |
18 | - /** |
|
19 | - * Current data for metadata |
|
20 | - * |
|
21 | - * @since 1.0.19 |
|
22 | - * @var array |
|
23 | - */ |
|
24 | - protected $current_data; |
|
18 | + /** |
|
19 | + * Current data for metadata |
|
20 | + * |
|
21 | + * @since 1.0.19 |
|
22 | + * @var array |
|
23 | + */ |
|
24 | + protected $current_data; |
|
25 | 25 | |
26 | - /** |
|
27 | - * Metadata data |
|
28 | - * |
|
29 | - * @since 1.0.19 |
|
30 | - * @var array |
|
31 | - */ |
|
32 | - protected $data; |
|
26 | + /** |
|
27 | + * Metadata data |
|
28 | + * |
|
29 | + * @since 1.0.19 |
|
30 | + * @var array |
|
31 | + */ |
|
32 | + protected $data; |
|
33 | 33 | |
34 | - /** |
|
35 | - * Constructor. |
|
36 | - * |
|
37 | - * @param array $meta Data to wrap behind this function. |
|
38 | - */ |
|
39 | - public function __construct( $meta = array() ) { |
|
40 | - $this->current_data = $meta; |
|
41 | - $this->apply_changes(); |
|
42 | - } |
|
34 | + /** |
|
35 | + * Constructor. |
|
36 | + * |
|
37 | + * @param array $meta Data to wrap behind this function. |
|
38 | + */ |
|
39 | + public function __construct( $meta = array() ) { |
|
40 | + $this->current_data = $meta; |
|
41 | + $this->apply_changes(); |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * When converted to JSON. |
|
46 | - * |
|
47 | - * @return object|array |
|
48 | - */ |
|
49 | - #[\ReturnTypeWillChange] |
|
50 | - public function jsonSerialize() { |
|
51 | - return $this->get_data(); |
|
52 | - } |
|
44 | + /** |
|
45 | + * When converted to JSON. |
|
46 | + * |
|
47 | + * @return object|array |
|
48 | + */ |
|
49 | + #[\ReturnTypeWillChange] |
|
50 | + public function jsonSerialize() { |
|
51 | + return $this->get_data(); |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * Merge changes with data and clear. |
|
56 | - */ |
|
57 | - public function apply_changes() { |
|
58 | - $this->data = $this->current_data; |
|
59 | - } |
|
54 | + /** |
|
55 | + * Merge changes with data and clear. |
|
56 | + */ |
|
57 | + public function apply_changes() { |
|
58 | + $this->data = $this->current_data; |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * Creates or updates a property in the metadata object. |
|
63 | - * |
|
64 | - * @param string $key Key to set. |
|
65 | - * @param mixed $value Value to set. |
|
66 | - */ |
|
67 | - public function __set( $key, $value ) { |
|
68 | - $this->current_data[ $key ] = $value; |
|
69 | - } |
|
61 | + /** |
|
62 | + * Creates or updates a property in the metadata object. |
|
63 | + * |
|
64 | + * @param string $key Key to set. |
|
65 | + * @param mixed $value Value to set. |
|
66 | + */ |
|
67 | + public function __set( $key, $value ) { |
|
68 | + $this->current_data[ $key ] = $value; |
|
69 | + } |
|
70 | 70 | |
71 | - /** |
|
72 | - * Checks if a given key exists in our data. This is called internally |
|
73 | - * by `empty` and `isset`. |
|
74 | - * |
|
75 | - * @param string $key Key to check if set. |
|
76 | - * |
|
77 | - * @return bool |
|
78 | - */ |
|
79 | - public function __isset( $key ) { |
|
80 | - return array_key_exists( $key, $this->current_data ); |
|
81 | - } |
|
71 | + /** |
|
72 | + * Checks if a given key exists in our data. This is called internally |
|
73 | + * by `empty` and `isset`. |
|
74 | + * |
|
75 | + * @param string $key Key to check if set. |
|
76 | + * |
|
77 | + * @return bool |
|
78 | + */ |
|
79 | + public function __isset( $key ) { |
|
80 | + return array_key_exists( $key, $this->current_data ); |
|
81 | + } |
|
82 | 82 | |
83 | - /** |
|
84 | - * Returns the value of any property. |
|
85 | - * |
|
86 | - * @param string $key Key to get. |
|
87 | - * @return mixed Property value or NULL if it does not exists |
|
88 | - */ |
|
89 | - public function __get( $key ) { |
|
90 | - if ( array_key_exists( $key, $this->current_data ) ) { |
|
91 | - return $this->current_data[ $key ]; |
|
92 | - } |
|
93 | - return null; |
|
94 | - } |
|
83 | + /** |
|
84 | + * Returns the value of any property. |
|
85 | + * |
|
86 | + * @param string $key Key to get. |
|
87 | + * @return mixed Property value or NULL if it does not exists |
|
88 | + */ |
|
89 | + public function __get( $key ) { |
|
90 | + if ( array_key_exists( $key, $this->current_data ) ) { |
|
91 | + return $this->current_data[ $key ]; |
|
92 | + } |
|
93 | + return null; |
|
94 | + } |
|
95 | 95 | |
96 | - /** |
|
97 | - * Return data changes only. |
|
98 | - * |
|
99 | - * @return array |
|
100 | - */ |
|
101 | - public function get_changes() { |
|
102 | - $changes = array(); |
|
103 | - foreach ( $this->current_data as $id => $value ) { |
|
104 | - if ( ! array_key_exists( $id, $this->data ) || $value !== $this->data[ $id ] ) { |
|
105 | - $changes[ $id ] = $value; |
|
106 | - } |
|
107 | - } |
|
108 | - return $changes; |
|
109 | - } |
|
96 | + /** |
|
97 | + * Return data changes only. |
|
98 | + * |
|
99 | + * @return array |
|
100 | + */ |
|
101 | + public function get_changes() { |
|
102 | + $changes = array(); |
|
103 | + foreach ( $this->current_data as $id => $value ) { |
|
104 | + if ( ! array_key_exists( $id, $this->data ) || $value !== $this->data[ $id ] ) { |
|
105 | + $changes[ $id ] = $value; |
|
106 | + } |
|
107 | + } |
|
108 | + return $changes; |
|
109 | + } |
|
110 | 110 | |
111 | - /** |
|
112 | - * Return all data as an array. |
|
113 | - * |
|
114 | - * @return array |
|
115 | - */ |
|
116 | - public function get_data() { |
|
117 | - return $this->data; |
|
118 | - } |
|
111 | + /** |
|
112 | + * Return all data as an array. |
|
113 | + * |
|
114 | + * @return array |
|
115 | + */ |
|
116 | + public function get_data() { |
|
117 | + return $this->data; |
|
118 | + } |
|
119 | 119 | } |