public function collect($post_id, string $key = ''): array
    {
        $post_id = (int) ($post_id ?? get_the_ID());

        if (!$post_id) { // Empty key is OK here.
            return []; // Not possible; empty array.
        }
        $value        = get_post_meta($post_id, $this->key($key), false);
        return $value = !is_array($value) ? [] : $value;
    }
public function collect($post_id, string $key = ''): array
    {
        $post_id = (int) ($post_id ?? get_the_ID());

        if (!$post_id) { // Empty key is OK here.
            return []; // Not possible; empty array.
        }
        $value        = get_post_meta($post_id, $this->key($key), false);
        return $value = !is_array($value) ? [] : $value;
    }
public function collect ( $ post_id , string $ key = '' ) : array { $ post_id = ( int ) ( $ post_id ?? get_the_ID ( ) ) ; if ( ! $ post_id ) { // Empty key is OK here. return [ ] ; // Not possible; empty array. } $ value = get_post_meta ( $ post_id , $ this -> key ( $ key ) , false ) ; return $ value = ! is_array ( $ value ) ? [ ] : $ value ; }
Collect meta values.

@since 160731 Post meta utils.

@param string|int|null $post_id Post ID; `null` = current.
@param string          $key     Meta key (unprefixed). If empty, returns all metadata.

@return array An array of meta values.
Collect meta values .