/** * RequirementReasoning constructor * * Used to construct this reasoning. Only the `reasonId`, `line` and `result` parameters * are required. The remaining parameters can be determined based on the reasonId and result instance. * * * @param int|string $reasonId The mapped reasonId * @param int $line The mapped line * @param \Pvra\AnalysisResult $result The result this reasoning applies to * @param string|null $version The required version. * @param null|string $msg The message related to this reasoning. If this parameter is set to `null` the message is * fetched from the `MessageLocator` attached to the result instance related to this instance. * @param array $data An array of additional data passed to the `MessageFormatter` */ public function __construct($reasonId, $line, AnalysisResult $result, $version = null, $msg = null, $data = []) { $this->reasonId = $reasonId; $this->line = $line; $this->msg = $msg; $this->result = $result; $this->data = $data; if ($version === null) { $this->version = Reason::getVersionFromReason($reasonId); } else { $this->version = $version; } }
/** * @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; }