<?php

namespace Hecate\Style\Parsers;

use Hecate\Lodash;

class CustomWidth extends BaseParser {


	public static $default = array(
		'type'        => '',
		'width' => array(
			'value' => '',
			'unit'  => '%',
		),
	);

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

		$properties = array();
		switch ( $data['type'] ) {
			case 'auto':
				$properties['flex'] = '1 1 0';
				break;
			case 'fitToContent':
				$properties['flex'] = '0 0 auto';
				break;
			case 'fixedWidth':
				$properties['flex']  = '0 0 auto';
				$properties['width'] = Utils::getValueWithUnit( $data['width'] );
				break;

		}

		return $properties;

	}
}
