/**
  * @see FingerprintValidator::validateFingerprint()
  *
  * @param Fingerprint $fingerprint
  * @param EntityId $entityId
  * @param string[]|null $languageCodes
  *
  * @return Result
  */
 public function validateFingerprint(Fingerprint $fingerprint, EntityId $entityId, array $languageCodes = null)
 {
     $labels = $fingerprint->getLabels()->toTextArray();
     $aliases = $fingerprint->getAliasGroups()->toTextArray();
     if ($languageCodes !== null) {
         $languageKeys = array_flip($languageCodes);
         $labels = array_intersect_key($labels, $languageKeys);
         $aliases = array_intersect_key($aliases, $languageKeys);
     }
     // Nothing to do if there are no labels AND no aliases.
     if (empty($labels) && empty($aliases)) {
         return Result::newSuccess();
     }
     return $this->duplicateDetector->detectLabelConflicts($entityId->getEntityType(), $labels, null, $entityId);
 }
 /**
  * @see FingerprintValidator::validateFingerprint()
  *
  * @param Fingerprint $fingerprint
  * @param EntityId $entityId
  * @param string[]|null $languageCodes
  *
  * @return Result
  */
 public function validateFingerprint(Fingerprint $fingerprint, EntityId $entityId, array $languageCodes = null)
 {
     $labels = $fingerprint->getLabels()->toTextArray();
     $descriptions = $fingerprint->getDescriptions()->toTextArray();
     if ($languageCodes !== null) {
         $languageKeys = array_flip($languageCodes);
         $labels = array_intersect_key($labels, $languageKeys);
         $descriptions = array_intersect_key($descriptions, $languageKeys);
     }
     // Nothing to do if there are no labels OR no descriptions, since
     // a conflict requires a label AND a description.
     if (empty($labels) || empty($descriptions)) {
         return Result::newSuccess();
     }
     return $this->duplicateDetector->detectLabelDescriptionConflicts($entityId->getEntityType(), $labels, $descriptions, $entityId);
 }
 /**
  * @dataProvider provideDetectLabelConflicts
  */
 public function testDetectLabelConflicts(array $world, $entityType, array $labels, array $aliases = null, $ignore, array $expectedErrors)
 {
     $detector = new LabelDescriptionDuplicateDetector(new MockTermIndex($world));
     $result = $detector->detectLabelConflicts($entityType, $labels, $aliases, $ignore);
     $this->assertResult($result, $expectedErrors);
 }