Skip to content

Commit 06ff3e3

Browse files
committed
Make sure Tag::applyRule() returns true if at least one tag is added
1 parent 06562a2 commit 06ff3e3

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/Entity/Operation.php

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,20 +143,25 @@ public function getTags(): Collection
143143
*/
144144
public function applyRule(TagRule $rule): bool
145145
{
146+
$addedTags = false;
147+
146148
$matches = $rule->isRegex()
147149
? \preg_match($rule->getMatchingPattern(), $this->details)
148150
: false !== \strpos($this->details, $rule->getMatchingPattern())
149151
;
150152

151153
if ($matches) {
152154
foreach ($rule->getTags() as $tag) {
153-
$this->addTag($tag);
155+
if (!$this->tags->contains($tag)) {
156+
$this->addTag($tag);
157+
$addedTags = true;
158+
}
154159
}
155160

156-
return true;
161+
return $addedTags;
157162
}
158163

159-
return false;
164+
return $addedTags;
160165
}
161166

162167
private function addTag(Tag $tag): void

0 commit comments

Comments
 (0)