Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
1 / 1
EmptyValueCleaner
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
1 / 1
6
100.00% covered (success)
100.00%
1 / 1
 omitEmptyValues
100.00% covered (success)
100.00%
6 / 6
100.00% covered (success)
100.00%
1 / 1
6
1<?php
2
3namespace MediaWiki\Extension\WikibaseManifest;
4
5class EmptyValueCleaner {
6
7    public function omitEmptyValues( $array ) {
8        foreach ( $array as $key => $value ) {
9            if ( is_array( $value ) ) {
10                $array[ $key ] = $this->omitEmptyValues( $array[ $key ] );
11            }
12            if ( $array[ $key ] === '' || $array[ $key ] === [] || $array[ $key ] === null ) {
13                unset( $array[ $key ] );
14            }
15        }
16        return $array;
17    }
18}