src/Data/FormatAbleObject.php
protected function unsetNullRecursively($data, $reference = null)
    {
        if (is_null($reference)) {
            $reference = $data;
        }

        $this->loop($reference, function ($key, $value) use (&$data) {
            if (is_array($data)) {
                if (is_null($value)) {
                    unset($data[$key]);
                } else {
                    $data[$key] = $this->unsetNullRecursively($value);
                }
            }

            if (is_object($data)) {
                if (is_null($value)) {
                    unset($data->$key);
                } else {
                    $data->$key = $this->unsetNullRecursively($value);
                }
            }
        });

        return $data;
    }
protected function unsetNullRecursively($data, $reference = null)
    {
        if (is_null($reference)) {
            $reference = $data;
        }

        $this->loop($reference, function ($key, $value) use (&$data) {
            if (is_array($data)) {
                if (is_null($value)) {
                    unset($data[$key]);
                } else {
                    $data[$key] = $this->unsetNullRecursively($value);
                }
            }

            if (is_object($data)) {
                if (is_null($value)) {
                    unset($data->$key);
                } else {
                    $data->$key = $this->unsetNullRecursively($value);
                }
            }
        });

        return $data;
    }
protected function unsetNullRecursively ( $ data , $ reference = null ) { if ( is_null ( $ reference ) ) { $ reference = $ data ; } $ this -> loop ( $ reference , function ( $ key , $ value ) use ( & $ data ) { if ( is_array ( $ data ) ) { if ( is_null ( $ value ) ) { unset ( $ data [ $ key ] ) ; } else { $ data [ $ key ] = $ this -> unsetNullRecursively ( $ value ) ; } } if ( is_object ( $ data ) ) { if ( is_null ( $ value ) ) { unset ( $ data -> $ key ) ; } else { $ data -> $ key = $ this -> unsetNullRecursively ( $ value ) ; } } } ) ; return $ data ; }
Unset null properties and keys of the given data.

@param array|object $data

@return array|object
Unset null properties and keys of the given data .