/** * Merges two results by rules * * @param ExpressionResult $expression * * @throws SyntaxException */ public function merge(ExpressionResult $expression) { if (self::TYPE_DATE === $this->getSourceType()) { /** @var Carbon $dateValue */ $dateValue = $this->getValue(); $dateValue->second($expression->getValue()->second); $dateValue->minute($expression->getValue()->minute); $dateValue->hour($expression->getValue()->hour); } elseif (self::TYPE_TIME === $this->getSourceType()) { $expression->merge($this); $this->value = $expression->getValue(); } else { throw new ExpressionDenied($expression->getVariableLabel()); } }