25 public static function isLocationsEqual($location1, $location2)
29 if(empty($location2[
$type]))
32 if($location1[
$type] <>
'' && $location2[
$type] <>
'')
35 $comparator = self::getConcreteComparatorClassaName(
$type);
37 if(!$comparator::isEntityEqual($location1[
$type], $location2[
$type]))
47 if(self::$replacement ===
null)
48 self::setReplacement();
50 return self::$replacement;
63 return self::getReplacement()->isCountryRussia($countryName);
71 private static function getConcreteComparatorClassaName(
$type)
87 public static function isEntityEqual($entity1, $entity2,
$type = '')
92 $comparator = self::getConcreteComparatorClassaName(
$type);
93 return $comparator::isEntityEqual($entity1, $entity2);
96 if(is_array($entity1) && !empty($entity1[
'NAME']))
98 $entity1N =
array(
'NAME' => $entity1[
'NAME']);
99 $entity1N[
'TYPE'] = !empty($entity1[
'TYPE']) ? $entity1[
'TYPE'] :
'';
103 $entity1N = static::normalize($entity1);
106 if(is_array($entity2) && !empty($entity2[
'NAME']))
108 $entity2N =
array(
'NAME' => $entity2[
'NAME']);
109 $entity2N[
'TYPE'] = !empty($entity2[
'TYPE']) ? $entity2[
'TYPE'] :
'';
113 $entity2N = static::normalize($entity2);
116 if($entity1N[
'NAME'] <>
'' && $entity2N[
'NAME'] <>
'')
117 if($entity1N[
'NAME'] != $entity2N[
'NAME'])
120 if($entity1N[
'TYPE'] <>
'' && $entity2N[
'TYPE'] <>
'')
121 if($entity1N[
'TYPE'] != $entity2N[
'TYPE'])
134 if(static::$variants ===
null)
136 static::setVariantsValues(
array());
139 return static::$variants;
147 public static function setVariants(
array $variants =
array())
149 foreach($variants as
$type => $v)
152 $comparator = self::getConcreteComparatorClassaName(
$type);
153 $comparator::setVariantsValues(
154 self::normalizeVariants($v)
161 $result = preg_replace(
'/\s*(\(.*\))/iu',
' ', $value);
162 $result = preg_replace(
'/[~\'\"\`\!\@\#\$\%\^\&\*\+\=\\\.\,\?\:\;\{\}\[\]\-]/iu',
' ',
$result);
176 $result[self::flatten(
$k)] = self::flatten($v);
181 public static function normalizeEntity(
$name,
$type)
184 $comparator = self::getConcreteComparatorClassaName(
$type);
185 return $comparator::normalize(
$name);
194 return array(
'NAME' =>
'',
'TYPE' =>
'');
197 $types = static::getTypes();
203 if(
$name == self::flatten($wrong))
210 foreach($types as
$type => $search)
212 if(!is_array($search))
217 foreach($search as $s)
220 $s = self::flatten($s);
222 if(mb_strpos(
$name, $s.
' ') !==
false)
223 $regexp =
'/^'.$s.
'\s+(.*)$/iu';
225 $regexp =
'/^(.*)\s+'.$s.
'$/iu';
238 'TYPE' => $resultType
248 $types = self::getReplacement()->getLocalityTypes();
255 if(is_array($types[
$type]) && !empty($types[
$type]))
257 foreach($types[
$type] as $t)
266 foreach($types as
$k => $v)
271 if(is_array($v) && !empty($v))
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)