/** * * @param \stdClass $rawEntry * @return boolean */ public function parse(\stdClass $rawEntryObject) { foreach ($this->requiredProperties as $requiredPropertyName) { if (!isset($rawEntryObject->{$requiredPropertyName})) { throw new ParserException('Missing required property "' . $requiredPropertyName . '"', 1); } } $this->entry = new Entry(); $this->entry->setLineNumber((int) $rawEntryObject->{self::LINE_PROPERTY_NAME}); $this->entry->setColumnNumber((int) $rawEntryObject->{self::CHARACTER_PROPERTY_NAME}); if (isset($rawEntryObject->{self::ID_PROPERTY_NAME})) { $this->entry->setId($rawEntryObject->{self::ID_PROPERTY_NAME}); } if (isset($rawEntryObject->{self::EVIDENCE_PROPERTY_NAME})) { $this->entry->setEvidence($rawEntryObject->{self::EVIDENCE_PROPERTY_NAME}); } if (isset($rawEntryObject->{self::RAw_PROPERTY_NAME})) { $this->entry->setRaw($rawEntryObject->{self::RAw_PROPERTY_NAME}); if ($this->expectsParameters($rawEntryObject->{self::RAw_PROPERTY_NAME})) { $this->entry->setParameters($this->getErrorParameters($rawEntryObject)); } } $this->entry->setReason($rawEntryObject->{self::REASON_PROPERTY_NAME}); return true; }
/** * * @param string $fieldName * @return mixed */ private function getEntryValue($fieldName) { if (in_array($fieldName, $this->standardFields)) { switch ($fieldName) { case self::ID_PROPERTY_NAME: return $this->entry->getId(); case self::RAw_PROPERTY_NAME: return $this->entry->getRaw(); case self::EVIDENCE_PROPERTY_NAME: return $this->entry->getEvidence(); case self::LINE_PROPERTY_NAME: return $this->entry->getLineNumber(); case self::CHARACTER_PROPERTY_NAME: return $this->entry->getColumnNumber(); case self::REASON_PROPERTY_NAME: return $this->entry->getReason(); } } $parameters = $this->entry->getParameters(); return isset($parameters[$fieldName]) ? $parameters[$fieldName] : null; }
/** * * @param \webignition\NodeJslintOutput\Entry\Entry $entry * @return boolean */ private function isTooManyErrorsEntry(Entry $entry) { return preg_match("/Too many errors\\. \\([0-9]{1,2}\\% scanned\\)\\./", $entry->getReason()) > 0; }