/** * {@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; }