Code Duplication    Length = 13-17 lines in 2 locations

src/Label/CommandHandler.php 1 location

@@ 162-174 (lines=13) @@
159
    /**
160
     * @param AbstractAddLabel $addLabel
161
     */
162
    private function createLabel(AbstractAddLabel $addLabel)
163
    {
164
        $label = Label::create(
165
            new UUID($this->uuidGenerator->generate()),
166
            new LabelName((string)$addLabel->getLabel()),
167
            Visibility::VISIBLE(),
168
            Privacy::PRIVACY_PUBLIC()
169
        );
170
        try {
171
            $this->save($label);
172
        } catch (UniqueConstraintException $exception) {
173
        }
174
    }
175
}
176

src/Label/ConstraintAwareLabelService.php 1 location

@@ 40-56 (lines=17) @@
37
    /**
38
     * @inheritdoc
39
     */
40
    public function createLabelAggregateIfNew(LabelName $labelName)
41
    {
42
        try {
43
            $labelAggregate = Label::create(
44
                new UUID($this->uuidGenerator->generate()),
45
                $labelName,
46
                Visibility::VISIBLE(),
47
                Privacy::PRIVACY_PUBLIC()
48
            );
49
50
            $this->labelRepository->save($labelAggregate);
51
52
            return $labelAggregate->getAggregateRootId();
53
        } catch (UniqueConstraintException $exception) {
54
            return null;
55
        }
56
    }
57
}
58