genkgo / camt

PHP Parser for CAMT messages
MIT License
81 stars 68 forks source link

getRelatedPartyDetails() doesn't exists #117

Closed rgendroz closed 2 years ago

rgendroz commented 2 years ago

I'm not an expert but I had an error on trying to get RelatedPartyDetails. It seems to be a wrong function denomination in RelatedParty.php:

public function getRelatedPartyType(): RelatedPartyTypeInterface

would not better be?

public function getRelatedPartyDetails(): RelatedPartyTypeInterface

thanks for your great job!

PowerKiKi commented 2 years ago

While RelatedPartyDetails could maybe make more sense, there is only 5 references to it in the entire project, and all in the same class. On the other hand RelatedPartyType is well established with 107 references all over the place.

Actually I'd be curious why you thought it would be RelatedPartyDetails in the first place, since it is not referenced anywhere public, and your IDE should easily autocomplete with the correct name.

Anyway I don't think it is worth introducing a breaking change for that. So I'll close for now, but feel free to keep the discussion going. Maybe others feel the same way as you...

rgendroz commented 2 years ago

Thanks for answer. I tried to access entries[0].transactionDetails[0].relatedParties[0].relatedPartyDetails.name but error said function getRelatedPartyDetails() doesn't exists. In the RelatedParty.php file, the variable is called RelatedPartyDetails but function called RelatedPartyType. So may I use entries[0].transactionDetails[0].relatedParties[0].relatedPartyType.name ?

PowerKiKi commented 2 years ago

You seem to be using an alternative syntax to access things. So I can't help you with that. But in native PHP that would be something like:

$reader = new Reader(Config::getDefault());
$message = $reader->readFile($myFilename);
$message->getEntries()[0]->getTransactionDetails()[0]->getRelatedParties()[0]->getRelatedPartyType()->getName();