/** * {@inheritdoc} * * If operand is a Reference with extract it. * It accepts only a Result instance since it is the only one result it can wrap. */ public function compute() { if ($this->operand instanceof ReferenceInterface) { $this->operand = $this->operand->getReference(); if (!$this->operand) { throw new \LogicException(sprintf('Operand can not be found in results set (%s).', $this->operand)); } } if (!$this->operand instanceof Result) { throw new \LogicException('Wrapper can wrap only a Amount\\Result instance.'); } $value = $this->field === self::VALUE ? $this->operand->getValue() : $this->operand->getComplement(); return $value; }
/** * {@inheritdoc} */ public function compute() { if ($this->left instanceof ReferenceInterface) { $this->left = $this->left->getReference(); } if ($this->right instanceof ReferenceInterface) { $this->right = $this->right->getReference(); } if ($this->left instanceof OperationInterface) { $this->left = $this->left->compute(); } if ($this->right instanceof OperationInterface) { $this->right = $this->right->compute(); } return $this->left->compute($this->operator, $this->right); }