コード例 #1
0
ファイル: AnalysisResult.php プロジェクト: suralc/pvra
 /**
  * @param int $reason
  * @param int $line
  * @param null|string $msg
  * @param array $data
  * @return $this
  */
 public function addLimit($reason, $line = -1, $msg = null, array $data = [])
 {
     $version = Reason::getVersionFromReason($reason);
     if ($version === false) {
         throw new \LogicException(sprintf('%s::%s requires a reason a version can be associated to. Use %s::addArbitraryLimit() to add any version with any reasoning to the result.', __CLASS__, __METHOD__, __CLASS__));
     }
     $this->addArbitraryVersionConstraint(self::VERSION_LIMIT_MIN, $version, $line, $msg, $reason, $data);
     return $this;
 }
コード例 #2
0
ファイル: Reasoning.php プロジェクト: suralc/pvra
 /**
  * @param mixed $offset
  * @return array|int|null|string
  */
 public function offsetGet($offset)
 {
     switch ($offset) {
         case 'data':
             return $this->data;
         case 'line':
             return $this->line;
         case 'version':
             return $this->version;
         case 'reason':
             return $this->reasonId;
         case 'reasonName':
             return Reason::getReasonNameFromValue($this->reasonId);
         case 'raw_msg':
             if ($this->msg !== null) {
                 return $this->msg;
             }
             return $this->getResult()->getMsgFormatter()->getLocator()->getMessage($this->reasonId);
         case 'targetId':
             return $this->getResult()->getAnalysisTargetId();
         case 'msg':
             if ($this->msg !== null) {
                 return $this->msg;
             }
             return $this->getResult()->getMsgFormatter()->getFormattedMessageFromId($this->reasonId, array_merge($this->data, [MessageFormatter::FORMAT_KEY_LINE => $this->line, MessageFormatter::FORMAT_KEY_REASON_ID => $this->reasonId, MessageFormatter::FORMAT_KEY_TARGET_ID => $this->getResult()->getAnalysisTargetId(), MessageFormatter::FORMAT_KEY_VERSION => $this->version, MessageFormatter::FORMAT_KEY_REASON_NAME => $this->offsetGet('reasonName')]));
     }
     return null;
 }