Code Coverage
 
Classes and Traits
Functions and Methods
Lines
Total
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 4
CRAP
0.00% covered (danger)
0.00%
0 / 21
CargoTableSchema
0.00% covered (danger)
0.00%
0 / 1
0.00% covered (danger)
0.00%
0 / 4
56
0.00% covered (danger)
0.00%
0 / 21
 newFromDBString
0.00% covered (danger)
0.00%
0 / 1
12
0.00% covered (danger)
0.00%
0 / 11
 toDBString
0.00% covered (danger)
0.00%
0 / 1
6
0.00% covered (danger)
0.00%
0 / 6
 removeField
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
 addField
0.00% covered (danger)
0.00%
0 / 1
2
0.00% covered (danger)
0.00%
0 / 2
<?php
/**
 * Ideally this would probably implement the "Iterator" interface, but that
 * seems like too much work for the limited usage this class gets.
 *
 * @author Yaron Koren
 * @ingroup Cargo
 */
class CargoTableSchema {
    public $mFieldDescriptions = [];
    public static function newFromDBString( $dbString ) {
        $tableSchema = new CargoTableSchema();
        $tableSchemaDBArray = unserialize( $dbString );
        if ( !is_array( $tableSchemaDBArray ) ) {
            throw new MWException( "Invalid field information found for table." );
        }
        foreach ( $tableSchemaDBArray as $fieldName => $fieldDBArray ) {
            $tableSchema->mFieldDescriptions[$fieldName] = CargoFieldDescription::newFromDBArray(
                $fieldDBArray );
        }
        return $tableSchema;
    }
    public function toDBString() {
        $tableSchemaDBArray = [];
        foreach ( $this->mFieldDescriptions as $fieldName => $fieldDesc ) {
            $tableSchemaDBArray[$fieldName] = $fieldDesc->toDBArray();
        }
        return serialize( $tableSchemaDBArray );
    }
    public function removeField( $fieldName ) {
        unset( $this->mFieldDescriptions[$fieldName] );
    }
    public function addField( $fieldName, $fieldDescription ) {
        $this->mFieldDescriptions[$fieldName] = $fieldDescription;
    }
}