protected function extractMetaFields(EventInterface $event, $fields, $unsetExtracted = true, $serialize = true)
    {
        $extracted = [
            'meta' => $event->getMetaInfo()
        ];

        if (!is_array($extracted['meta'])) {
            return $extracted;
        }

        if (!$fields ||
            empty($extracted['meta'])
        ) {
            if ($serialize) {
                $extracted['meta'] = $this->serialize($extracted['meta']);
            }

            return $extracted;
        }

        if ($fields === true) {
            $extracted += $extracted['meta'];

            if (!$unsetExtracted) {
                if ($serialize) {
                    $extracted['meta'] = $this->serialize($extracted['meta']);
                }

                return $extracted;
            }

            $extracted['meta'] = $serialize ? $this->serialize([]) : [];

            return $extracted;
        }

        if (is_array($fields)) {
            foreach ($fields as $name => $alias) {
                if (!is_string($name)) {
                    $name = $alias;
                }

                $extracted[$alias] = Hash::get($extracted['meta'], $name);
                if ($unsetExtracted) {
                    $extracted['meta'] = Hash::remove($extracted['meta'], $name);
                }
            }
        }

        if ($serialize) {
            $extracted['meta'] = $this->serialize($extracted['meta']);
        }

        return $extracted;
    }
protected function extractMetaFields(EventInterface $event, $fields, $unsetExtracted = true, $serialize = true)
    {
        $extracted = [
            'meta' => $event->getMetaInfo()
        ];

        if (!is_array($extracted['meta'])) {
            return $extracted;
        }

        if (!$fields ||
            empty($extracted['meta'])
        ) {
            if ($serialize) {
                $extracted['meta'] = $this->serialize($extracted['meta']);
            }

            return $extracted;
        }

        if ($fields === true) {
            $extracted += $extracted['meta'];

            if (!$unsetExtracted) {
                if ($serialize) {
                    $extracted['meta'] = $this->serialize($extracted['meta']);
                }

                return $extracted;
            }

            $extracted['meta'] = $serialize ? $this->serialize([]) : [];

            return $extracted;
        }

        if (is_array($fields)) {
            foreach ($fields as $name => $alias) {
                if (!is_string($name)) {
                    $name = $alias;
                }

                $extracted[$alias] = Hash::get($extracted['meta'], $name);
                if ($unsetExtracted) {
                    $extracted['meta'] = Hash::remove($extracted['meta'], $name);
                }
            }
        }

        if ($serialize) {
            $extracted['meta'] = $this->serialize($extracted['meta']);
        }

        return $extracted;
    }
protected function extractMetaFields ( EventInterface $ event , $ fields , $ unsetExtracted = true , $ serialize = true ) { $ extracted = [ 'meta' => $ event -> getMetaInfo ( ) ] ; if ( ! is_array ( $ extracted [ 'meta' ] ) ) { return $ extracted ; } if ( ! $ fields || empty ( $ extracted [ 'meta' ] ) ) { if ( $ serialize ) { $ extracted [ 'meta' ] = $ this -> serialize ( $ extracted [ 'meta' ] ) ; } return $ extracted ; } if ( $ fields === true ) { $ extracted += $ extracted [ 'meta' ] ; if ( ! $ unsetExtracted ) { if ( $ serialize ) { $ extracted [ 'meta' ] = $ this -> serialize ( $ extracted [ 'meta' ] ) ; } return $ extracted ; } $ extracted [ 'meta' ] = $ serialize ? $ this -> serialize ( [ ] ) : [ ] ; return $ extracted ; } if ( is_array ( $ fields ) ) { foreach ( $ fields as $ name => $ alias ) { if ( ! is_string ( $ name ) ) { $ name = $ alias ; } $ extracted [ $ alias ] = Hash :: get ( $ extracted [ 'meta' ] , $ name ) ; if ( $ unsetExtracted ) { $ extracted [ 'meta' ] = Hash :: remove ( $ extracted [ 'meta' ] , $ name ) ; } } } if ( $ serialize ) { $ extracted [ 'meta' ] = $ this -> serialize ( $ extracted [ 'meta' ] ) ; } return $ extracted ; }
Extracts the metadata fields from the audit event object.

@param \AuditStash\EventInterface $event The event object from which to extract the metadata fields.
@param array|bool $fields Which/whether meta data fields should be extracted.
@param bool $unsetExtracted Whether the fields extracted from the meta data should be unset.
@param bool $serialize Whether to serialize fields that are expected to hold array data.
@return array
Extracts the metadata fields from the audit event object .