src/Formatters/MetaFormatter.php
public function format($data)
    {
        if (!$data->hasProperty('meta')) {
            return $data;
        }

        // Loop through the meta arrays/objects/whatever
        foreach ($data->getProperty('meta') as $meta) {
            $regex = false;

            // Check if the meta array is valid
            if (!$this->metaKeyExists($meta) && !($regex = $this->metaKeyIsRegex($meta))) {
                continue;
            }

            // Get the property
            if ($regex) {
                $property = $this->getRegexProperty($regex, $regex['value']);
            } else {
                $property = $this->metaFields[$meta['meta_key']];
            }

            // Get the value
            $value = $this->getUnserializedValue($meta);

            // Set it
            $data->setProperty($property, $value);
        }

        $data->unsetProperty('meta');

        return $data;
    }
public function format($data)
    {
        if (!$data->hasProperty('meta')) {
            return $data;
        }

        // Loop through the meta arrays/objects/whatever
        foreach ($data->getProperty('meta') as $meta) {
            $regex = false;

            // Check if the meta array is valid
            if (!$this->metaKeyExists($meta) && !($regex = $this->metaKeyIsRegex($meta))) {
                continue;
            }

            // Get the property
            if ($regex) {
                $property = $this->getRegexProperty($regex, $regex['value']);
            } else {
                $property = $this->metaFields[$meta['meta_key']];
            }

            // Get the value
            $value = $this->getUnserializedValue($meta);

            // Set it
            $data->setProperty($property, $value);
        }

        $data->unsetProperty('meta');

        return $data;
    }
public function format ( $ data ) { if ( ! $ data -> hasProperty ( 'meta' ) ) { return $ data ; } // Loop through the meta arrays/objects/whatever foreach ( $ data -> getProperty ( 'meta' ) as $ meta ) { $ regex = false ; // Check if the meta array is valid if ( ! $ this -> metaKeyExists ( $ meta ) && ! ( $ regex = $ this -> metaKeyIsRegex ( $ meta ) ) ) { continue ; } // Get the property if ( $ regex ) { $ property = $ this -> getRegexProperty ( $ regex , $ regex [ 'value' ] ) ; } else { $ property = $ this -> metaFields [ $ meta [ 'meta_key' ] ] ; } // Get the value $ value = $ this -> getUnserializedValue ( $ meta ) ; // Set it $ data -> setProperty ( $ property , $ value ) ; } $ data -> unsetProperty ( 'meta' ) ; return $ data ; }
Format the meta fields from the given data.

@param FormatAble $data

@return FormatAble
Format the meta fields from the given data .