| Conditions | 7 |
| Paths | 11 |
| Total Lines | 29 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | <?php |
||
| 18 | public static function parse( $input, $is_option ) { |
||
| 19 | if ( is_null( $input ) ) { |
||
| 20 | return null; |
||
| 21 | } |
||
| 22 | |||
| 23 | if ( ! is_array( $input ) ) { |
||
| 24 | self::throw_exception( __( 'Please provide an array or a json to be used for the update.', 'crb' ) ); |
||
| 25 | } |
||
| 26 | |||
| 27 | if ( $is_option ) { |
||
| 28 | return $input; |
||
| 29 | } |
||
| 30 | |||
| 31 | $parsed_data = []; |
||
| 32 | |||
| 33 | foreach ( $input as $index => $group ) { |
||
| 34 | foreach ( $group as $key => $value ) { |
||
| 35 | $new_key = $key; |
||
| 36 | |||
| 37 | if ( $key !== 'group' ) { |
||
| 38 | $new_key = Helper::prepare_meta_name( $key ); |
||
| 39 | } |
||
| 40 | |||
| 41 | $parsed_data[ $index ][ $new_key ] = $value; |
||
| 42 | } |
||
| 43 | } |
||
| 44 | |||
| 45 | return $parsed_data; |
||
| 46 | } |
||
| 47 | } |