Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 1
CRAP
0.00% covered (danger)
0.00%
0 / 1
CollaborationKitSerialization
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 1
12
0.00% covered (danger)
0.00%
0 / 1
 getSerialization
0.00% covered (danger)
0.00%
0 / 7
0.00% covered (danger)
0.00%
0 / 1
12
1<?php
2
3/**
4 * A class to prepare a "human editable" serialization of data in CollaborationKit.
5 * In the general case, blocks of data are separated by a fixed number of hyphens.
6 * The blocks of text within do not contain keys, but the sequence of blocks is
7 * defined by the content model.
8 *
9 * @file
10 */
11
12class CollaborationKitSerialization {
13
14    // Main splitter
15    const SERIALIZATION_SPLIT = "\n-----------------------\n";
16
17    /**
18     * Prepares the "human editable" serialization
19     *
20     * @param array $content The contents to serialize, in sequential order
21     * @return string
22     */
23    public static function getSerialization( $content ) {
24        $retString = '';
25        $numberOfItems = count( $content );
26        for ( $i = 0; $i < $numberOfItems; $i++ ) {
27            $retString .= $content[$i];
28            // Don't add splitter after the last block
29            if ( $i != $numberOfItems - 1 ) {
30                $retString .= self::SERIALIZATION_SPLIT;
31            }
32        }
33        return $retString;
34    }
35}