<?php

namespace Hecate\Style\Parsers;

use Hecate\Lodash;

class General extends BaseParser {


	public static $default = array(
		'opacity'        => '',
		'textAlign'      => '',
		'justifyContent' => '',
		'alignItems'     => '',
	);

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

		$properties = array();

		if ( $data['opacity'] || $data['opacity'] === '0' || $data['opacity'] === 0 ) {
			$properties['opacity'] = $data['opacity'];
		}
		if ( $data['textAlign'] ) {
			$properties['text-align']      = $data['textAlign'];
			$properties['justify-content'] = Utils::getTextAlignToFlexValue( $data['textAlign'] );
		}
		if ( $data['justifyContent'] ) {
			$properties['justify-content'] = $data['justifyContent'];
		}
		if ( $data['alignItems'] ) {
			$properties['align-items'] = $data['alignItems'];
		}

		return $properties;

	}
}
