Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
CRAP
100.00% covered (success)
100.00%
6 / 6
EmptyValueCleaner
100.00% covered (success)
100.00%
1 / 1
100.00% covered (success)
100.00%
1 / 1
6
100.00% covered (success)
100.00%
6 / 6
 omitEmptyValues
100.00% covered (success)
100.00%
1 / 1
6
100.00% covered (success)
100.00%
6 / 6
<?php
namespace MediaWiki\Extension\WikibaseManifest;
class EmptyValueCleaner {
    public function omitEmptyValues( $array ) {
        foreach ( $array as $key => $value ) {
            if ( is_array( $value ) ) {
                $array[ $key ] = $this->omitEmptyValues( $array[ $key ] );
            }
            if ( $array[ $key ] === '' || $array[ $key ] === [] || $array[ $key ] === null ) {
                unset( $array[ $key ] );
            }
        }
        return $array;
    }
}