Пример #1
0
 /**
  * @param \ReflectionProperty[]|\ReflectionMethod[] $sourceMembers
  * @param MappingOptionsInterface $mappingOptions
  * @throws \Papper\NotSupportedException
  * @return MemberGetterInterface
  */
 public function createMemberGetter(array $sourceMembers, MappingOptionsInterface $mappingOptions)
 {
     if (count($sourceMembers) == 1) {
         return $this->createReflectionGetter($sourceMembers[0]);
     }
     $propertyPath = implode('.', array_map(function (\Reflector $member) use($mappingOptions) {
         /** @var $member \ReflectionProperty|\ReflectionMethod */
         return NamingHelper::possibleName($member->name, $mappingOptions->getSourcePrefixes()) ?: $member->getName();
     }, $sourceMembers));
     return new PropertyAccessGetter($propertyPath);
 }
Пример #2
0
 private function nameMatches($sourceMemberName, $destMemberName, MappingOptionsInterface $mappingOptions)
 {
     $possibleSourceNames = NamingHelper::possibleNames($sourceMemberName, $mappingOptions->getSourcePrefixes());
     $possibleDestNames = NamingHelper::possibleNames($destMemberName, $mappingOptions->getDestinationPrefixes());
     return count(array_uintersect($possibleSourceNames, $possibleDestNames, function ($a, $b) {
         return strcasecmp($a, $b);
     })) > 0;
 }