Skip to content

Commit

Permalink
Merge pull request #17 from aternosorg/fixAddInsight
Browse files Browse the repository at this point in the history
set the analysis before isEqual check.
  • Loading branch information
matthi4s authored Jan 9, 2024
2 parents 900a28c + 8374e2e commit e14a34d
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Analysis/Analysis.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,15 @@ public function setInsights(array $insights = []): static
*/
public function addInsight(InsightInterface $insight): static
{
$insight->setAnalysis($this);

foreach ($this as $existingInsight) {
if (get_class($insight) === get_class($existingInsight) && $existingInsight->isEqual($insight)) {
$existingInsight->increaseCounter();
return $this;
}
}

$insight->setAnalysis($this);
$this->insights[] = $insight;
return $this;
}
Expand Down

0 comments on commit e14a34d

Please sign in to comment.