<?php


namespace Hecate\Style;

/*
 * A rule si designed to add all the styling for a styled component of a component
 */

use Hecate\Lodash;

class Rule {

	private $style          = array();
	public $state           = null;
	public $media           = null;
	public $componentPartId = null;

	public function __construct( $style, $options ) {
		$options               = Lodash::merge(
			array(
				'media'           => Constants::MEDIA_DESKTOP,
				'state'           => Constants::MEDIA_DESKTOP,
				'componentPartId' => null,
			),
			$options
		);
		$this->style           = $style;
		$this->componentPartId = $options['componentPartId'];
		$this->media           = $options['media'];
		$this->state           = $options['state'];
	}

	public function addStyle( $style ) {
		$this->style = Lodash::merge( $this->style, $style );
	}

	public function getStyle() {
		return $this->style;
	}

	public function getMedia() {
		return $this->media;
	}

	public function getState() {
		return $this->state;
	}
	public function getComponentPartId() {
		return $this->componentPartId;
	}

	public function ruleMatchesQuery( $componentPartId, $media, $state ) {
		return  $componentPartId === $this->componentPartId &&
				$media === $this->media &&
				$state === $this->state;
	}
}
