/** * @return DuplicateCriterion */ public static function createCriterion($typeID, array $matches) { if ($typeID === DuplicateIndexType::PERSON) { return DuplicatePersonCriterion::createFromMatches($matches); } elseif ($typeID === DuplicateIndexType::ORGANIZATION) { return DuplicateOrganizationCriterion::createFromMatches($matches); } elseif ($typeID === DuplicateIndexType::COMMUNICATION_PHONE || $typeID === DuplicateIndexType::COMMUNICATION_EMAIL) { return DuplicateCommunicationCriterion::createFromMatches($matches); } else { throw new Main\NotSupportedException("Criterion type(s): '" . DuplicateIndexType::resolveName($typeID) . "' is not supported in current context"); } }
public function calculateEntityCount(DuplicateCriterion $criterion, array $options = null) { $count = $this->innerCalculateEntityCount($criterion, $options); $matches = $criterion->getMatches(); $name = isset($matches['NAME']) ? $matches['NAME'] : ''; $secondName = isset($matches['SECOND_NAME']) ? $matches['SECOND_NAME'] : ''; $lastName = isset($matches['LAST_NAME']) ? $matches['LAST_NAME'] : ''; if ($secondName !== '' && $name !== '') { $count += $this->innerCalculateEntityCount(DuplicatePersonCriterion::createFromMatches(array('LAST_NAME' => $lastName, 'NAME' => $name)), $options); } if ($name !== '') { $count += $this->innerCalculateEntityCount(DuplicatePersonCriterion::createFromMatches(array('LAST_NAME' => $lastName)), $options); } return $count; }