<?php

namespace Hecate\Style\Parsers;

use Hecate\Lodash;

class Margin extends BaseParser {


    public static $default = array(
        'left'   => array(
            'value' => '',
            'unit'  => 'px',
        ),
        'right'  => array(
            'value' => '',
            'unit'  => 'px',
        ),
        'top'    => array(
            'value' => '',
            'unit'  => 'px',
        ),
        'bottom' => array(
            'value' => '',
            'unit'  => 'px',
        ),
    );

	public static function parse( $data = array() ) {
		$mergedData = Lodash::merge( static::$default, $data );

		$result = array();
		foreach ( $mergedData as $propertyKey => $value ) {

			if ( Utils::getValueWithUnitIsNotEmpty( $value ) ) {
				$result[ "margin-{$propertyKey}" ] = Utils::getValueWithUnit( $value );
			}
		}

		return $result;

	}
}
